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 |
#from vob.color.spaces import YSTtoRGB,gamma |
31 |
|
|
32 |
|
# Luminance weights of the RGB primaries used in YST color space functions |
33 |
|
Wr = 0.212671 |
34 |
|
Wg = 0.715160 |
35 |
|
Wb = 0.072169 |
36 |
|
|
37 |
|
#Wr,Wg,Wb = 0.3, 0.59, 0.11 |
38 |
|
|
39 |
|
# Gamma correction used with the perceptual non-linearity in YtoL and LtoY |
40 |
|
# conversion functions. |
41 |
|
# |
42 |
|
gamma = 2.2 |
43 |
|
# |
44 |
|
# The uncorrected display gamma of PC's is typically 2.2, i.e., |
45 |
|
# RGB values map to physical intensities with an exponent of 2.2. |
46 |
|
# So, gamma correction of 2.2 here should result in linear |
47 |
|
# intensity. (The CIE L* computation assumes linear intensity). |
48 |
|
|
49 |
|
def YSTtoRGB(v): |
50 |
|
n = 1.0 / (Wr+Wg+Wb) |
51 |
|
mat = [ [n, n*(Wg+Wb), n*(Wb - Wg) / math.sqrt(3) ], |
52 |
|
[n, n*(-Wr), n*(2*Wb + Wr) / math.sqrt(3) ], |
53 |
|
[n, n*(-Wr), n*-(2*Wg + Wr) / math.sqrt(3) ] ] |
54 |
|
|
55 |
|
return [ mat[0][0] * v[0] + mat[0][1] * v[1] + mat[0][2] * v[2], |
56 |
|
mat[1][0] * v[0] + mat[1][1] * v[1] + mat[1][2] * v[2], |
57 |
|
mat[2][0] * v[0] + mat[2][1] * v[1] + mat[2][2] * v[2] ] |
58 |
|
|
59 |
|
|
60 |
|
def getcol(l, x, y): |
61 |
|
col = YSTtoRGB( (.4, .44 * x, .44 * y) ) |
62 |
|
col = map(lambda x: x**(1./gamma), col) |
63 |
|
|
64 |
|
return col |
65 |
|
|
66 |
|
|
67 |
class Scene: |
class Scene: |
68 |
def __init__(self): |
def __init__(self): |
73 |
SlideLin("ang", 0, .1, "Rotation", "Prior", "Next"), |
SlideLin("ang", 0, .1, "Rotation", "Prior", "Next"), |
74 |
) |
) |
75 |
def scene(self, vs): |
def scene(self, vs): |
76 |
vs.put( background((0,0,0)) ) |
|
77 |
|
vs.put( background( getcol(.4, 0, 0) ) ) |
78 |
|
|
79 |
code = """ |
code = """ |
80 |
Begin QUAD_STRIP |
Begin QUAD_STRIP |
83 |
min = [1,1,1] |
min = [1,1,1] |
84 |
max = [0,0,0] |
max = [0,0,0] |
85 |
|
|
86 |
for ang in range(0,361): |
for ang in range(0,365,1): |
87 |
a = ang / 180. * math.pi |
a = ang / 180. * math.pi |
88 |
|
|
89 |
x = math.cos(a) |
x = math.cos(a) |
90 |
y = math.sin(a) |
y = math.sin(a) |
91 |
|
|
92 |
col = YSTtoRGB( (.5, .55 * x, .55 * y) ) |
col = getcol(.4, .44 * x, .44 * y) |
93 |
|
|
94 |
for i in range(0,3): |
for i in range(0,3): |
95 |
if col[i] < min[i]: min[i] = col[i] |
if col[i] < min[i]: min[i] = col[i] |
99 |
Color %s %s %s |
Color %s %s %s |
100 |
Vertex %s %s |
Vertex %s %s |
101 |
Vertex %s %s |
Vertex %s %s |
102 |
""" % (col[0], col[1], col[2], x, y, .9 * x, .9 * y) |
""" % (col[0], col[1], col[2], x, y, .5 * x, .5 * y) |
103 |
|
|
104 |
code += """ |
code += """ |
105 |
End |
End |
106 |
""" |
""" |
107 |
|
|
108 |
print "MIN: %4.2f %4.2f %4.2f" % tuple(min) |
print "MIN: %5.3f %5.3f %5.3f" % tuple(min) |
109 |
print "MAX: %4.2f %4.2f %4.2f" % tuple(max) |
print "MAX: %5.3f %5.3f %5.3f" % tuple(max) |
110 |
|
|
111 |
cs = vs.orthoCS(0, "cs1", 0, 512, 384, 300, 300); |
cs = vs.orthoCS(0, "cs1", 0, 512, 384, 300, 300); |
112 |
|
|