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