summaryrefslogtreecommitdiffstats
path: root/libdimension-python/wrapper.pyx
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-11-28 21:15:44 -0500
committerTavian Barnes <tavianator@gmail.com>2011-11-28 21:23:39 -0500
commit3cff39f02c54eb0f06835e1e0b6a2f6f02d0b5cb (patch)
treebbc25d189e8b63ff5f4751498c4858f97acb155e /libdimension-python/wrapper.pyx
parent458736a57bf8573de747e28f816b77248f998b85 (diff)
downloaddimension-3cff39f02c54eb0f06835e1e0b6a2f6f02d0b5cb.tar.xz
Be more consistent about using sRGB in the client.
Also, expose the sRGB C and C^-1 functions.
Diffstat (limited to 'libdimension-python/wrapper.pyx')
-rw-r--r--libdimension-python/wrapper.pyx23
1 files changed, 12 insertions, 11 deletions
diff --git a/libdimension-python/wrapper.pyx b/libdimension-python/wrapper.pyx
index 5431e75..2ed85e0 100644
--- a/libdimension-python/wrapper.pyx
+++ b/libdimension-python/wrapper.pyx
@@ -465,6 +465,8 @@ cdef class Color:
return _sRGBColor(dmnsn_color_mul(rhs, (<Color>lhs)._sRGB))
else:
return _sRGBColor(dmnsn_color_mul(lhs, (<Color?>rhs)._sRGB))
+ def __truediv__(Color lhs not None, double rhs):
+ return _sRGBColor(dmnsn_color_mul(1/rhs, lhs._sRGB))
def __richcmp__(lhs, rhs, int op):
cdef clhs = Color(lhs)
@@ -831,9 +833,9 @@ cdef class Diffuse(Finish):
Keyword arguments:
diffuse -- the intensity of the diffuse reflection
"""
- cdef dmnsn_color gray = dmnsn_color_mul(diffuse, dmnsn_white)
- diffuse = dmnsn_color_intensity(dmnsn_color_from_sRGB(gray))
- self._finish.diffuse = dmnsn_new_lambertian(diffuse)
+ self._finish.diffuse = dmnsn_new_lambertian(
+ dmnsn_sRGB_inverse_gamma(diffuse)
+ )
cdef class Phong(Finish):
"""Phong specular highlight."""
@@ -841,7 +843,10 @@ cdef class Phong(Finish):
"""
Create a Phong highlight.
"""
- self._finish.specular = dmnsn_new_phong(strength, size)
+ self._finish.specular = dmnsn_new_phong(
+ dmnsn_sRGB_inverse_gamma(strength),
+ size
+ )
cdef class Reflection(Finish):
"""Reflective finish."""
@@ -857,10 +862,8 @@ cdef class Reflection(Finish):
if max is None:
max = min
- # Use sRGB value because Reflection(0.5) should really mean "reflect half
- # the light"
- self._finish.reflection = dmnsn_new_basic_reflection(Color(min)._sRGB,
- Color(max)._sRGB,
+ self._finish.reflection = dmnsn_new_basic_reflection(Color(min)._c,
+ Color(max)._c,
falloff)
############
@@ -1317,9 +1320,7 @@ cdef class PointLight(Light):
location -- the origin of the light rays
color -- the color and intensity of the light
"""
- # Take the sRGB component because "color = 0.5*White" should really mean
- # a half-intensity white light
- self._light = dmnsn_new_point_light(Vector(location)._v, Color(color)._sRGB)
+ self._light = dmnsn_new_point_light(Vector(location)._v, Color(color)._c)
Light.__init__(self)
###########