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