Code Duplication    Length = 27-27 lines in 2 locations

tcod/libtcodpy.py 2 locations

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