Skip to content

Commit b5081ef

Browse files
committed
Update and add Console dtypes.
1 parent 39007c9 commit b5081ef

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Added
1616
- New functions:
1717
- `tcod.event.get_keyboard_state`
1818
- `tcod.event.get_modifier_state`
19+
- Added `tcod.console.rgb_graphic` and `tcod.console.rgba_graphic` dtypes.
1920

2021
Fixed
2122
- Contexts now give a more useful error when pickled.

tcod/console.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ def _fmt(string: str) -> bytes:
2323

2424
_root_console = None
2525

26+
rgba_graphic = np.dtype([("ch", np.intc), ("fg", "4u1"), ("bg", "4u1")])
27+
"""A NumPy :any:`dtype` compatible with :any:`Console.buffer`.
28+
29+
.. versionadded:: 12.3
30+
"""
31+
32+
rgb_graphic = np.dtype([("ch", np.intc), ("fg", "3u1"), ("bg", "3u1")])
33+
"""A NumPy :any:`dtype` compatible with :any:`Console.tiles_rgb`.
34+
35+
.. versionadded:: 12.3
36+
"""
2637

2738
class Console:
2839
"""A console object containing a grid of characters with
@@ -77,13 +88,13 @@ class Console:
7788
Added an alpha channel to the color types.
7889
"""
7990

80-
DTYPE = np.dtype([("ch", np.intc), ("fg", "(4,)u1"), ("bg", "(4,)u1")])
91+
DTYPE = np.dtype([("ch", np.intc), ("fg", "4u1"), ("bg", "4u1")])
8192

8293
# A structured arrays type with the added "fg_rgb" and "bg_rgb" fields.
8394
_DTYPE_RGB = np.dtype(
8495
{
8596
"names": ["ch", "fg", "bg"],
86-
"formats": [np.int32, "(3,)u1", "(3,)u1"],
97+
"formats": [np.int32, "3u1", "3u1"],
8798
"offsets": [0, 4, 8],
8899
"itemsize": 12,
89100
}

0 commit comments

Comments
 (0)