summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-07-13 22:23:54 -0600
committerTavian Barnes <tavianator@gmail.com>2011-07-13 22:24:10 -0600
commit063b2bd9a3d7b29a79bb0c301173a08446d5e4e9 (patch)
tree31d2a2ed6d6703b1d799499dac8177f98ebae802
parentde659b311b756b75cbe06cf2ed02c7ab779915bd (diff)
downloaddimension-063b2bd9a3d7b29a79bb0c301173a08446d5e4e9.tar.xz
Implement quick_color for Pigments.
-rw-r--r--libdimension-python/dimension.pxd1
-rw-r--r--libdimension-python/dimension.pyx28
2 files changed, 19 insertions, 10 deletions
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 = (<Pigment>arg)._pigment
- DMNSN_INCREF(self._pigment)
+ if quick_color is not None:
+ if self._pigment == NULL:
+ if isinstance(quick_color, Pigment):
+ self._pigment = (<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 #