Changeset 4772 for libcaca


Ignore:
Timestamp:
Feb 19, 2011, 2:11:34 PM (8 years ago)
Author:
Alex Foulon
Message:
  • Make mask an optional argument for Canvas.blit method.
  • Drawing and put_figchar methods now can handle utf8 chars.
Location:
libcaca/trunk/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/python/caca/canvas.py

    r4771 r4772  
    254254        return _lib.caca_get_canvas_handle_y(self)
    255255
    256     def blit(self, x, y, cv, mask):
     256    def blit(self, x, y, cv, mask=None):
    257257        """ Blit canvas onto another one.
    258258
     
    266266            ]
    267267        _lib.caca_blit.restype  = ctypes.c_int
     268
     269        if mask is None:
     270            mask = NullCanvas()
    268271
    269272        return _lib.caca_blit(self, x, y, cv, mask)
     
    513516        _lib.caca_draw_line.restype  = ctypes.c_int
    514517
    515         return _lib.caca_draw_line(self, x1, y1, x2, y2, ord(ch))
     518        try:
     519            ch = ord(ch)
     520        except TypeError:
     521            ch = utf8_to_utf32(ch)
     522
     523        return _lib.caca_draw_line(self, x1, y1, x2, y2, ch)
    516524
    517525    def draw_polyline(self, array_x, array_y, n, ch):
     
    528536        _lib.caca_draw_polyline.restype  = ctypes.c_int
    529537
    530         return _lib.caca_draw_polyline(self, array_x, array_y, n, ord(ch))
     538        try:
     539            ch = ord(ch)
     540        except TypeError:
     541            ch = utf8_to_utf32(ch)
     542
     543        return _lib.caca_draw_polyline(self, array_x, array_y, n, ch)
    531544
    532545    def draw_thin_line(self, x1, y1, x2, y2):
     
    572585        _lib.caca_draw_circle.restype  = ctypes.c_int
    573586
    574         return _lib.caca_draw_circle(self, x, y, r, ord(ch))
     587        try:
     588            ch = ord(ch)
     589        except TypeError:
     590            ch = utf8_to_utf32(ch)
     591
     592        return _lib.caca_draw_circle(self, x, y, r, ch)
    575593
    576594    def draw_ellipse(self, xo, yo, a, b, ch):
     
    589607        _lib.caca_draw_ellipse.restype  = ctypes.c_int
    590608
    591         return _lib.caca_draw_ellipse(self, xo, yo, a, b, ord(ch))
     609        try:
     610            ch = ord(ch)
     611        except TypeError:
     612            ch = utf8_to_utf32(ch)
     613
     614        return _lib.caca_draw_ellipse(self, xo, yo, a, b, ch)
    592615
    593616    def draw_thin_ellipse(self, xo, yo, a, b):
     
    621644        _lib.caca_fill_ellipse.restype  = ctypes.c_int
    622645
    623         return _lib.caca_fill_ellipse(self, xo, yo, a, b, ord(ch))
     646        try:
     647            ch = ord(ch)
     648        except TypeError:
     649            ch = utf8_to_utf32(ch)
     650
     651        return _lib.caca_fill_ellipse(self, xo, yo, a, b, ch)
    624652
    625653    def draw_box(self, x, y, width, height, ch):
     
    637665        _lib.caca_draw_box.restype  = ctypes.c_int
    638666
    639         return _lib.caca_draw_box(self, x, y, width, height, ord(ch))
     667        try:
     668            ch = ord(ch)
     669        except TypeError:
     670            ch = utf8_to_utf32(ch)
     671
     672        return _lib.caca_draw_box(self, x, y, width, height, ch)
    640673
    641674    def draw_thin_box(self, x, y, width, height):
     
    685718        _lib.caca_fill_box.restype  = ctypes.c_int
    686719
    687         return _lib.caca_fill_box(self, x, y, width, height, ord(ch))
     720        try:
     721            ch = ord(ch)
     722        except TypeError:
     723            ch = utf8_to_utf32(ch)
     724
     725        return _lib.caca_fill_box(self, x, y, width, height, ch)
    688726
    689727    def draw_triangle(self, x1, y1, x2, y2, x3, y3, ch):
     
    704742        _lib.caca_draw_triangle.restype  = ctypes.c_int
    705743
    706         return _lib.caca_draw_triangle(self, x1, y1, x2, y2, x3, y3, ord(ch))
     744        try:
     745            ch = ord(ch)
     746        except TypeError:
     747            ch = utf8_to_utf32(ch)
     748
     749        return _lib.caca_draw_triangle(self, x1, y1, x2, y2, x3, y3, ch)
    707750
    708751    def draw_thin_triangle(self, x1, y1, x2, y2, x3, y3):
     
    734777        _lib.caca_fill_triangle.restype  = ctypes.c_int
    735778
    736         return _lib.caca_fill_triangle(self, x1, y1, x2, y2, x3, y3, ord(ch))
     779        try:
     780            ch = ord(ch)
     781        except TypeError:
     782            ch = utf8_to_utf32(ch)
     783
     784        return _lib.caca_fill_triangle(self, x1, y1, x2, y2, x3, y3, ch)
    737785
    738786    def fill_triangle_textured(self, coords, tex, uv):
     
    9761024        _lib.caca_put_figchar.restype  = ctypes.c_int
    9771025
    978         return _lib.caca_put_figchar(self, ord(ch))
     1026        try:
     1027            ch = ord(ch)
     1028        except TypeError:
     1029            ch = utf8_to_utf32(ch)
     1030 
     1031        return _lib.caca_put_figchar(self, ch)
    9791032
    9801033    def flush_figlet(self):
  • libcaca/trunk/python/examples/figfont.py

    r4710 r4772  
    4343        sys.exit(2)
    4444
    45     for c in sys.argv[2]:
     45    for c in sys.argv[2].decode('utf8'):
    4646        color += 4
    4747        cv.set_color_ansi(1+(color % 15), caca.COLOR_TRANSPARENT)
Note: See TracChangeset for help on using the changeset viewer.