Code Duplication    Length = 19-19 lines in 2 locations

tcod/libtcodpy.py 2 locations

@@ 685-703 (lines=19) @@
682
683
    lib.TCOD_console_fill_foreground(_cdata(con), cr, cg, cb)
684
685
def console_fill_background(con,r,g,b):
686
    if len(r) != len(g) or len(r) != len(b):
687
        raise TypeError('R, G and B must all have the same size.')
688
    if (_numpy_available() and isinstance(r, _numpy.ndarray) and
689
        isinstance(g, _numpy.ndarray) and isinstance(b, _numpy.ndarray)):
690
        #numpy arrays, use numpy's ctypes functions
691
        r = _numpy.ascontiguousarray(r, dtype=_numpy.intc)
692
        g = _numpy.ascontiguousarray(g, dtype=_numpy.intc)
693
        b = _numpy.ascontiguousarray(b, dtype=_numpy.intc)
694
        cr = ffi.cast('int *', r.ctypes.data)
695
        cg = ffi.cast('int *', g.ctypes.data)
696
        cb = ffi.cast('int *', b.ctypes.data)
697
    else:
698
        # otherwise convert using ffi arrays
699
        cr = ffi.new('int[]', r)
700
        cg = ffi.new('int[]', g)
701
        cb = ffi.new('int[]', b)
702
703
    lib.TCOD_console_fill_background(_cdata(con), cr, cg, cb)
704
705
def console_fill_char(con,arr):
706
    if (_numpy_available() and isinstance(arr, _numpy.ndarray) ):
@@ 665-683 (lines=19) @@
662
        lib.TCOD_console_delete(con)
663
664
# fast color filling
665
def console_fill_foreground(con,r,g,b):
666
    if len(r) != len(g) or len(r) != len(b):
667
        raise TypeError('R, G and B must all have the same size.')
668
    if (_numpy_available() and isinstance(r, _numpy.ndarray) and
669
        isinstance(g, _numpy.ndarray) and isinstance(b, _numpy.ndarray)):
670
        #numpy arrays, use numpy's ctypes functions
671
        r = _numpy.ascontiguousarray(r, dtype=_numpy.intc)
672
        g = _numpy.ascontiguousarray(g, dtype=_numpy.intc)
673
        b = _numpy.ascontiguousarray(b, dtype=_numpy.intc)
674
        cr = ffi.cast('int *', r.ctypes.data)
675
        cg = ffi.cast('int *', g.ctypes.data)
676
        cb = ffi.cast('int *', b.ctypes.data)
677
    else:
678
        # otherwise convert using ffi arrays
679
        cr = ffi.new('int[]', r)
680
        cg = ffi.new('int[]', g)
681
        cb = ffi.new('int[]', b)
682
683
    lib.TCOD_console_fill_foreground(_cdata(con), cr, cg, cb)
684
685
def console_fill_background(con,r,g,b):
686
    if len(r) != len(g) or len(r) != len(b):