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 |
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] |
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) |