From 063b2bd9a3d7b29a79bb0c301173a08446d5e4e9 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 13 Jul 2011 22:23:54 -0600 Subject: Implement quick_color for Pigments. --- libdimension-python/dimension.pxd | 1 + libdimension-python/dimension.pyx | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'libdimension-python') diff --git a/libdimension-python/dimension.pxd b/libdimension-python/dimension.pxd index f675501..8b0ccbb 100644 --- a/libdimension-python/dimension.pxd +++ b/libdimension-python/dimension.pxd @@ -226,6 +226,7 @@ cdef extern from "../libdimension/dimension.h": ctypedef struct dmnsn_pigment: dmnsn_matrix trans + dmnsn_color quick_color ctypedef enum dmnsn_pigment_map_flags: DMNSN_PIGMENT_MAP_REGULAR diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx index ff97f73..cc8efdb 100644 --- a/libdimension-python/dimension.pyx +++ b/libdimension-python/dimension.pyx @@ -580,19 +580,25 @@ cdef class Pigment: def __cinit__(self): self._pigment = NULL - def __init__(self, arg = None): + def __init__(self, quick_color = None): """ Create a Pigment. With an arguement, create a solid pigment of that color. Otherwise, create a base Pigment. + + Keyword arguments: + quick_color -- the object's quick color for low-quality renders """ - if arg is not None: - if isinstance(arg, Pigment): - self._pigment = (arg)._pigment - DMNSN_INCREF(self._pigment) + if quick_color is not None: + if self._pigment == NULL: + if isinstance(quick_color, Pigment): + self._pigment = (quick_color)._pigment + DMNSN_INCREF(self._pigment) + else: + self._pigment = dmnsn_new_solid_pigment(Color(quick_color)._c) else: - self._pigment = dmnsn_new_solid_pigment(Color(arg)._c) + self._pigment.quick_color = Color(quick_color)._c def __dealloc__(self): dmnsn_delete_pigment(self._pigment) @@ -613,7 +619,8 @@ cdef _Pigment(dmnsn_pigment *pigment): cdef class ColorMap(Pigment): """A color map""" - def __init__(self, Pattern pattern not None, map, bool sRGB not None = True): + def __init__(self, Pattern pattern not None, map, bool sRGB not None = True, + *args, **kwargs): """ Create a ColorMap. @@ -641,11 +648,12 @@ cdef class ColorMap(Pigment): DMNSN_INCREF(pattern._pattern) self._pigment = dmnsn_new_color_map_pigment(pattern._pattern, color_map, flags) - Pigment.__init__(self) + Pigment.__init__(self, *args, **kwargs) cdef class PigmentMap(Pigment): """A pigment map.""" - def __init__(self, Pattern pattern not None, map, bool sRGB not None = True): + def __init__(self, Pattern pattern not None, map, bool sRGB not None = True, + *args, **kwargs): """ Create a PigmentMap. @@ -680,7 +688,7 @@ cdef class PigmentMap(Pigment): DMNSN_INCREF(pattern._pattern) self._pigment = dmnsn_new_pigment_map_pigment(pattern._pattern, pigment_map, flags) - Pigment.__init__(self) + Pigment.__init__(self, *args, **kwargs) ############ # Finishes # -- cgit v1.2.3