/[libvob]/libvob/vob/demo/lava/color.py
ViewVC logotype

Diff of /libvob/vob/demo/lava/color.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by jvk, Mon Sep 1 14:03:36 2003 UTC revision 1.4 by tjl, Mon Sep 22 08:49:01 2003 UTC
# Line 27  from vob.putil.misc import * Line 27  from vob.putil.misc import *
27  from vob.putil.demokeys import *  from vob.putil.demokeys import *
28  from vob.paper.texcache import getCachedTexture  from vob.paper.texcache import getCachedTexture
29    
30  #from vob.color.spaces import YSTtoRGB,gamma  import vob.color.spaces
31    from vob.color.spaces import YSTtoRGB,gamma,set_temp,linear_to_monitor
 # 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] ]  
32    
33    #set_temp(6500)
34    
35  def getcol(l, x, y):  def getcol(l, x, y):
36      col = YSTtoRGB( (l,  x, y) )      col = YSTtoRGB( (l,  x, y) )
37      col = map(lambda x: x**(1./gamma), col)      col = linear_to_monitor(col)
38    
39      return col      return col
40            
41    
42  class Scene:  class Scene:
43        """Color circle"""
44      def __init__(self):      def __init__(self):
45          self.key = KeyPresses(          self.key = KeyPresses(
46              self,              self,
47              SlideLin("l1", 200, 20, "l1", "Left", "Right"),              SlideLin("c", .5, .1, "chroma", "Left", "Right"),
48              SlideLin("l2", 300, 20, "l2", "Up", "Down"),              SlideLin("Y", .5, .05, "luminance", "Down", "Up"),
49              SlideLin("ang", 0, .1, "Rotation", "Prior", "Next"),              SlideLin("ang", 0, .1, "Rotation", "Prior", "Next"),
50          )          )
51      def scene(self, vs):      def scene(self, vs):
52                    vs.put( background( getcol(self.Y, 0, 0) ) )
         vs.put( background( getcol(.4, 0, 0) ) )  
53    
54          code = """          code = """
55          Begin QUAD_STRIP          Begin QUAD_STRIP
# Line 89  class Scene: Line 64  class Scene:
64              x = math.cos(a)              x = math.cos(a)
65              y = math.sin(a)              y = math.sin(a)
66    
67              col = getcol(.4, .41 * x, .41 * y)              col = getcol(self.Y, self.c * x, self.c * y)
68    
69              for i in range(0,3):              for i in range(0,3):
70                  if col[i] < min[i]: min[i] = col[i]                  if col[i] < min[i]: min[i] = col[i]
# Line 108  class Scene: Line 83  class Scene:
83          print "MIN: %5.3f %5.3f %5.3f" % tuple(min)          print "MIN: %5.3f %5.3f %5.3f" % tuple(min)
84          print "MAX: %5.3f %5.3f %5.3f" % tuple(max)          print "MAX: %5.3f %5.3f %5.3f" % tuple(max)
85    
86          cs = vs.orthoCS(0, "cs1", 0, 512, 384, 300, 300);          cs = vs.orthoCS(0, "cs1", 0, 512, 384, 300, -300);
87                    
88          vs.map.put(getDList(code), cs)          vs.map.put(getDList(code), cs)

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26