"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "python/caca/canvas.py" between
libcaca-0.99.beta19.tar.gz and libcaca-0.99.beta20.tar.bz2

About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).

canvas.py  (libcaca-0.99.beta19):canvas.py  (libcaca-0.99.beta20.tar.bz2)
skipping to change at line 24 skipping to change at line 24
""" Libcaca Python bindings """ """ Libcaca Python bindings """
import ctypes import ctypes
import errno import errno
from caca import _lib, utf8_to_utf32, utf32_to_utf8 from caca import _lib, utf8_to_utf32, utf32_to_utf8
from caca import _PYTHON3, _str_to_bytes, _bytes_to_str from caca import _PYTHON3, _str_to_bytes, _bytes_to_str
from caca.font import _Font from caca.font import _Font
class _CanvasStruct(ctypes.Structure):
pass
class _Canvas(object): class _Canvas(object):
""" Model for Canvas objects. """ Model for Canvas objects.
""" """
def __init__(self): def __init__(self):
self._cv = 0 self._cv = None
def from_param(self): def from_param(self):
""" Required by ctypes module to call object as parameter of """ Required by ctypes module to call object as parameter of
a C function. a C function.
""" """
return self._cv return self._cv
def __str__(self): def __str__(self):
return "<CacaCanvas %dx%d>" % (self.get_width(), self.get_height()) return "<CacaCanvas %dx%d>" % (self.get_width(), self.get_height())
def __del__(self): def __del__(self):
if self._cv > 0: if self._cv and _lib is not None:
self._free() self._free()
def _free(self): def _free(self):
""" Free a libcaca canvas. """ Free a libcaca canvas.
""" """
_lib.caca_free_canvas.argtypes = [_Canvas] _lib.caca_free_canvas.argtypes = [_Canvas]
_lib.caca_free_canvas.restype = ctypes.c_int _lib.caca_free_canvas.restype = ctypes.c_int
return _lib.caca_free_canvas(self) return _lib.caca_free_canvas(self)
skipping to change at line 64 skipping to change at line 67
first parameter. first parameter.
""" """
def __init__(self, width=0, height=0, pointer=None): def __init__(self, width=0, height=0, pointer=None):
""" Canvas constructor. """ Canvas constructor.
width -- the desired canvas width width -- the desired canvas width
height -- the desired canvas height height -- the desired canvas height
pointer -- pointer to libcaca canvas pointer -- pointer to libcaca canvas
""" """
_lib.caca_create_canvas.argtypes = [ctypes.c_int, ctypes.c_int] _lib.caca_create_canvas.argtypes = [ctypes.c_int, ctypes.c_int]
_lib.caca_create_canvas.restype = ctypes.POINTER(_CanvasStruct)
if pointer is None: if pointer is None:
try: try:
self._cv = _lib.caca_create_canvas(width, height) self._cv = _lib.caca_create_canvas(width, height)
except ctypes.ArgumentError: except ctypes.ArgumentError:
self._cv = 0 self._cv = 0
raise CanvasError("Specified width or height is invalid") raise CanvasError("Specified width or height is invalid")
else: else:
if self._cv == 0: if self._cv == 0:
err = ctypes.c_int.in_dll(_lib, "errno") err = ctypes.c_int.in_dll(_lib, "errno")
 End of changes. 4 change blocks. 
2 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)