libtcodpy.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:warhexer 作者: sudasana 项目源码 文件源码
def console_fill_foreground(con,r,g,b) :
    if len(r) != len(g) or len(r) != len(b):
        raise TypeError('R, G and B must all have the same size.')

    if (numpy_available and isinstance(r, numpy.ndarray) and
        isinstance(g, numpy.ndarray) and isinstance(b, numpy.ndarray)):
        #numpy arrays, use numpy's ctypes functions
        r = numpy.ascontiguousarray(r, dtype=numpy.int_)
        g = numpy.ascontiguousarray(g, dtype=numpy.int_)
        b = numpy.ascontiguousarray(b, dtype=numpy.int_)
        cr = r.ctypes.data_as(POINTER(c_int))
        cg = g.ctypes.data_as(POINTER(c_int))
        cb = b.ctypes.data_as(POINTER(c_int))
    else:
        # otherwise convert using ctypes arrays
        cr = (c_int * len(r))(*r)
        cg = (c_int * len(g))(*g)
        cb = (c_int * len(b))(*b)

    _lib.TCOD_console_fill_foreground(con, cr, cg, cb)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号