[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] libvob/vob/demo/lava color.py
From: |
Janne V. Kujala |
Subject: |
[ff-cvs] libvob/vob/demo/lava color.py |
Date: |
Mon, 01 Sep 2003 09:11:17 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Janne V. Kujala <address@hidden> 03/09/01 09:11:17
Modified files:
vob/demo/lava : color.py
Log message:
better circle
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/lava/color.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: libvob/vob/demo/lava/color.py
diff -u libvob/vob/demo/lava/color.py:1.1 libvob/vob/demo/lava/color.py:1.2
--- libvob/vob/demo/lava/color.py:1.1 Mon Sep 1 08:22:17 2003
+++ libvob/vob/demo/lava/color.py Mon Sep 1 09:11:17 2003
@@ -27,7 +27,42 @@
from vob.putil.demokeys import *
from vob.paper.texcache import getCachedTexture
-from vob.color.spaces import YSTtoRGB
+#from vob.color.spaces import YSTtoRGB,gamma
+
+# Luminance weights of the RGB primaries used in YST color space functions
+Wr = 0.212671
+Wg = 0.715160
+Wb = 0.072169
+
+#Wr,Wg,Wb = 0.3, 0.59, 0.11
+
+# Gamma correction used with the perceptual non-linearity in YtoL and LtoY
+# conversion functions.
+#
+gamma = 2.2
+#
+# The uncorrected display gamma of PC's is typically 2.2, i.e.,
+# RGB values map to physical intensities with an exponent of 2.2.
+# So, gamma correction of 2.2 here should result in linear
+# intensity. (The CIE L* computation assumes linear intensity).
+
+def YSTtoRGB(v):
+ n = 1.0 / (Wr+Wg+Wb)
+ mat = [ [n, n*(Wg+Wb), n*(Wb - Wg) / math.sqrt(3) ],
+ [n, n*(-Wr), n*(2*Wb + Wr) / math.sqrt(3) ],
+ [n, n*(-Wr), n*-(2*Wg + Wr) / math.sqrt(3) ] ]
+
+ return [ mat[0][0] * v[0] + mat[0][1] * v[1] + mat[0][2] * v[2],
+ mat[1][0] * v[0] + mat[1][1] * v[1] + mat[1][2] * v[2],
+ mat[2][0] * v[0] + mat[2][1] * v[1] + mat[2][2] * v[2] ]
+
+
+def getcol(l, x, y):
+ col = YSTtoRGB( (.4, .44 * x, .44 * y) )
+ col = map(lambda x: x**(1./gamma), col)
+
+ return col
+
class Scene:
def __init__(self):
@@ -38,7 +73,8 @@
SlideLin("ang", 0, .1, "Rotation", "Prior", "Next"),
)
def scene(self, vs):
- vs.put( background((0,0,0)) )
+
+ vs.put( background( getcol(.4, 0, 0) ) )
code = """
Begin QUAD_STRIP
@@ -47,13 +83,13 @@
min = [1,1,1]
max = [0,0,0]
- for ang in range(0,361):
+ for ang in range(0,365,1):
a = ang / 180. * math.pi
x = math.cos(a)
y = math.sin(a)
- col = YSTtoRGB( (.5, .55 * x, .55 * y) )
+ col = getcol(.4, .44 * x, .44 * y)
for i in range(0,3):
if col[i] < min[i]: min[i] = col[i]
@@ -63,14 +99,14 @@
Color %s %s %s
Vertex %s %s
Vertex %s %s
- """ % (col[0], col[1], col[2], x, y, .9 * x, .9 * y)
+ """ % (col[0], col[1], col[2], x, y, .5 * x, .5 * y)
code += """
End
"""
- print "MIN: %4.2f %4.2f %4.2f" % tuple(min)
- print "MAX: %4.2f %4.2f %4.2f" % tuple(max)
+ print "MIN: %5.3f %5.3f %5.3f" % tuple(min)
+ print "MAX: %5.3f %5.3f %5.3f" % tuple(max)
cs = vs.orthoCS(0, "cs1", 0, 512, 384, 300, 300);