|
@@ 1095-1122 (lines=28) @@
|
| 1092 |
|
lib.TCOD_console_fill_foreground(con.console_c if con else ffi.NULL, |
| 1093 |
|
cr, cg, cb) |
| 1094 |
|
|
| 1095 |
|
def console_fill_background(con, r, g, b): |
| 1096 |
|
"""Fill the backgound of a console with r,g,b. |
| 1097 |
|
|
| 1098 |
|
Args: |
| 1099 |
|
con (Console): Any Console instance. |
| 1100 |
|
r (Sequence[int]): An array of integers with a length of width*height. |
| 1101 |
|
g (Sequence[int]): An array of integers with a length of width*height. |
| 1102 |
|
b (Sequence[int]): An array of integers with a length of width*height. |
| 1103 |
|
""" |
| 1104 |
|
if len(r) != len(g) or len(r) != len(b): |
| 1105 |
|
raise TypeError('R, G and B must all have the same size.') |
| 1106 |
|
if (isinstance(r, _np.ndarray) and isinstance(g, _np.ndarray) and |
| 1107 |
|
isinstance(b, _np.ndarray)): |
| 1108 |
|
#numpy arrays, use numpy's ctypes functions |
| 1109 |
|
r = _np.ascontiguousarray(r, dtype=_np.intc) |
| 1110 |
|
g = _np.ascontiguousarray(g, dtype=_np.intc) |
| 1111 |
|
b = _np.ascontiguousarray(b, dtype=_np.intc) |
| 1112 |
|
cr = ffi.cast('int *', r.ctypes.data) |
| 1113 |
|
cg = ffi.cast('int *', g.ctypes.data) |
| 1114 |
|
cb = ffi.cast('int *', b.ctypes.data) |
| 1115 |
|
else: |
| 1116 |
|
# otherwise convert using ffi arrays |
| 1117 |
|
cr = ffi.new('int[]', r) |
| 1118 |
|
cg = ffi.new('int[]', g) |
| 1119 |
|
cb = ffi.new('int[]', b) |
| 1120 |
|
|
| 1121 |
|
lib.TCOD_console_fill_background(con.console_c if con else ffi.NULL, |
| 1122 |
|
cr, cg, cb) |
| 1123 |
|
|
| 1124 |
|
def console_fill_char(con,arr): |
| 1125 |
|
"""Fill the character tiles of a console with an array. |
|
@@ 1066-1093 (lines=28) @@
|
| 1063 |
|
lib.TCOD_console_delete(con) |
| 1064 |
|
|
| 1065 |
|
# fast color filling |
| 1066 |
|
def console_fill_foreground(con, r, g, b): |
| 1067 |
|
"""Fill the foregound of a console with r,g,b. |
| 1068 |
|
|
| 1069 |
|
Args: |
| 1070 |
|
con (Console): Any Console instance. |
| 1071 |
|
r (Sequence[int]): An array of integers with a length of width*height. |
| 1072 |
|
g (Sequence[int]): An array of integers with a length of width*height. |
| 1073 |
|
b (Sequence[int]): An array of integers with a length of width*height. |
| 1074 |
|
""" |
| 1075 |
|
if len(r) != len(g) or len(r) != len(b): |
| 1076 |
|
raise TypeError('R, G and B must all have the same size.') |
| 1077 |
|
if (isinstance(r, _np.ndarray) and isinstance(g, _np.ndarray) and |
| 1078 |
|
isinstance(b, _np.ndarray)): |
| 1079 |
|
#numpy arrays, use numpy's ctypes functions |
| 1080 |
|
r = _np.ascontiguousarray(r, dtype=_np.intc) |
| 1081 |
|
g = _np.ascontiguousarray(g, dtype=_np.intc) |
| 1082 |
|
b = _np.ascontiguousarray(b, dtype=_np.intc) |
| 1083 |
|
cr = ffi.cast('int *', r.ctypes.data) |
| 1084 |
|
cg = ffi.cast('int *', g.ctypes.data) |
| 1085 |
|
cb = ffi.cast('int *', b.ctypes.data) |
| 1086 |
|
else: |
| 1087 |
|
# otherwise convert using ffi arrays |
| 1088 |
|
cr = ffi.new('int[]', r) |
| 1089 |
|
cg = ffi.new('int[]', g) |
| 1090 |
|
cb = ffi.new('int[]', b) |
| 1091 |
|
|
| 1092 |
|
lib.TCOD_console_fill_foreground(con.console_c if con else ffi.NULL, |
| 1093 |
|
cr, cg, cb) |
| 1094 |
|
|
| 1095 |
|
def console_fill_background(con, r, g, b): |
| 1096 |
|
"""Fill the backgound of a console with r,g,b. |