|
@@ 1037-1050 (lines=14) @@
|
| 1034 |
|
""" |
| 1035 |
|
if len(r) != len(g) or len(r) != len(b): |
| 1036 |
|
raise TypeError('R, G and B must all have the same size.') |
| 1037 |
|
if (_numpy_available() and isinstance(r, _numpy.ndarray) and |
| 1038 |
|
isinstance(g, _numpy.ndarray) and isinstance(b, _numpy.ndarray)): |
| 1039 |
|
#numpy arrays, use numpy's ctypes functions |
| 1040 |
|
r = _numpy.ascontiguousarray(r, dtype=_numpy.intc) |
| 1041 |
|
g = _numpy.ascontiguousarray(g, dtype=_numpy.intc) |
| 1042 |
|
b = _numpy.ascontiguousarray(b, dtype=_numpy.intc) |
| 1043 |
|
cr = ffi.cast('int *', r.ctypes.data) |
| 1044 |
|
cg = ffi.cast('int *', g.ctypes.data) |
| 1045 |
|
cb = ffi.cast('int *', b.ctypes.data) |
| 1046 |
|
else: |
| 1047 |
|
# otherwise convert using ffi arrays |
| 1048 |
|
cr = ffi.new('int[]', r) |
| 1049 |
|
cg = ffi.new('int[]', g) |
| 1050 |
|
cb = ffi.new('int[]', b) |
| 1051 |
|
|
| 1052 |
|
lib.TCOD_console_fill_background(_cdata(con), cr, cg, cb) |
| 1053 |
|
|
|
@@ 1009-1022 (lines=14) @@
|
| 1006 |
|
""" |
| 1007 |
|
if len(r) != len(g) or len(r) != len(b): |
| 1008 |
|
raise TypeError('R, G and B must all have the same size.') |
| 1009 |
|
if (_numpy_available() and isinstance(r, _numpy.ndarray) and |
| 1010 |
|
isinstance(g, _numpy.ndarray) and isinstance(b, _numpy.ndarray)): |
| 1011 |
|
#numpy arrays, use numpy's ctypes functions |
| 1012 |
|
r = _numpy.ascontiguousarray(r, dtype=_numpy.intc) |
| 1013 |
|
g = _numpy.ascontiguousarray(g, dtype=_numpy.intc) |
| 1014 |
|
b = _numpy.ascontiguousarray(b, dtype=_numpy.intc) |
| 1015 |
|
cr = ffi.cast('int *', r.ctypes.data) |
| 1016 |
|
cg = ffi.cast('int *', g.ctypes.data) |
| 1017 |
|
cb = ffi.cast('int *', b.ctypes.data) |
| 1018 |
|
else: |
| 1019 |
|
# otherwise convert using ffi arrays |
| 1020 |
|
cr = ffi.new('int[]', r) |
| 1021 |
|
cg = ffi.new('int[]', g) |
| 1022 |
|
cb = ffi.new('int[]', b) |
| 1023 |
|
|
| 1024 |
|
lib.TCOD_console_fill_foreground(_cdata(con), cr, cg, cb) |
| 1025 |
|
|