Code Duplication    Length = 28-28 lines in 2 locations

tcod/libtcodpy.py 2 locations

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