|
@@ 943-969 (lines=27) @@
|
| 940 |
|
#numpy arrays, use numpy's ctypes functions |
| 941 |
|
r = _numpy.ascontiguousarray(r, dtype=_numpy.intc) |
| 942 |
|
g = _numpy.ascontiguousarray(g, dtype=_numpy.intc) |
| 943 |
|
b = _numpy.ascontiguousarray(b, dtype=_numpy.intc) |
| 944 |
|
cr = ffi.cast('int *', r.ctypes.data) |
| 945 |
|
cg = ffi.cast('int *', g.ctypes.data) |
| 946 |
|
cb = ffi.cast('int *', b.ctypes.data) |
| 947 |
|
else: |
| 948 |
|
# otherwise convert using ffi arrays |
| 949 |
|
cr = ffi.new('int[]', r) |
| 950 |
|
cg = ffi.new('int[]', g) |
| 951 |
|
cb = ffi.new('int[]', b) |
| 952 |
|
|
| 953 |
|
lib.TCOD_console_fill_foreground(_cdata(con), cr, cg, cb) |
| 954 |
|
|
| 955 |
|
def console_fill_background(con, r, g, b): |
| 956 |
|
"""Fill the backgound of a console with r,g,b. |
| 957 |
|
|
| 958 |
|
Args: |
| 959 |
|
con (Console): Any Console instance. |
| 960 |
|
r (Sequence[int]): An array of integers with a length of width*height. |
| 961 |
|
g (Sequence[int]): An array of integers with a length of width*height. |
| 962 |
|
b (Sequence[int]): An array of integers with a length of width*height. |
| 963 |
|
""" |
| 964 |
|
if len(r) != len(g) or len(r) != len(b): |
| 965 |
|
raise TypeError('R, G and B must all have the same size.') |
| 966 |
|
if (_numpy_available() and isinstance(r, _numpy.ndarray) and |
| 967 |
|
isinstance(g, _numpy.ndarray) and isinstance(b, _numpy.ndarray)): |
| 968 |
|
#numpy arrays, use numpy's ctypes functions |
| 969 |
|
r = _numpy.ascontiguousarray(r, dtype=_numpy.intc) |
| 970 |
|
g = _numpy.ascontiguousarray(g, dtype=_numpy.intc) |
| 971 |
|
b = _numpy.ascontiguousarray(b, dtype=_numpy.intc) |
| 972 |
|
cr = ffi.cast('int *', r.ctypes.data) |
|
@@ 915-941 (lines=27) @@
|
| 912 |
|
def console_blit(src, x, y, w, h, dst, xdst, ydst, ffade=1.0,bfade=1.0): |
| 913 |
|
"""Blit the console src from x,y,w,h to console dst at xdst,ydst.""" |
| 914 |
|
lib.TCOD_console_blit(_cdata(src), x, y, w, h, |
| 915 |
|
_cdata(dst), xdst, ydst, ffade, bfade) |
| 916 |
|
|
| 917 |
|
def console_set_key_color(con, col): |
| 918 |
|
"""Set a consoles blit transparent color.""" |
| 919 |
|
lib.TCOD_console_set_key_color(_cdata(con), col) |
| 920 |
|
|
| 921 |
|
def console_delete(con): |
| 922 |
|
con = _cdata(con) |
| 923 |
|
if con == ffi.NULL: |
| 924 |
|
lib.TCOD_console_delete(con) |
| 925 |
|
|
| 926 |
|
# fast color filling |
| 927 |
|
def console_fill_foreground(con, r, g, b): |
| 928 |
|
"""Fill the foregound of a console with r,g,b. |
| 929 |
|
|
| 930 |
|
Args: |
| 931 |
|
con (Console): Any Console instance. |
| 932 |
|
r (Sequence[int]): An array of integers with a length of width*height. |
| 933 |
|
g (Sequence[int]): An array of integers with a length of width*height. |
| 934 |
|
b (Sequence[int]): An array of integers with a length of width*height. |
| 935 |
|
""" |
| 936 |
|
if len(r) != len(g) or len(r) != len(b): |
| 937 |
|
raise TypeError('R, G and B must all have the same size.') |
| 938 |
|
if (_numpy_available() and isinstance(r, _numpy.ndarray) and |
| 939 |
|
isinstance(g, _numpy.ndarray) and isinstance(b, _numpy.ndarray)): |
| 940 |
|
#numpy arrays, use numpy's ctypes functions |
| 941 |
|
r = _numpy.ascontiguousarray(r, dtype=_numpy.intc) |
| 942 |
|
g = _numpy.ascontiguousarray(g, dtype=_numpy.intc) |
| 943 |
|
b = _numpy.ascontiguousarray(b, dtype=_numpy.intc) |
| 944 |
|
cr = ffi.cast('int *', r.ctypes.data) |