/[gzz]/gzz/gfx/demo/irregu3.py
ViewVC logotype

Diff of /gzz/gfx/demo/irregu3.py

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

revision 1.27 by jvk, Tue Oct 29 09:43:44 2002 UTC revision 1.28 by jvk, Tue Oct 29 11:53:52 2002 UTC
# Line 32  profiles.append("STD") Line 32  profiles.append("STD")
32  def init(profile):  def init(profile):
33      global tex, texinv      global tex, texinv
34      global texenv_inner, texenv_outer, alphalevel, w0, w1      global texenv_inner, texenv_outer, alphalevel, w0, w1
35      global colmap0, colmap1      global colmap0, colmap1, angles
36      global using_shader, using_secondary_color      global using_shader, using_secondary_color
37    
38      using_shader = 0      using_shader = 0
# Line 89  def init(profile): Line 89  def init(profile):
89          def colmap0(dotvec): return (1,1,1)          def colmap0(dotvec): return (1,1,1)
90          def colmap1(dotvec): return (1,1,1)          def colmap1(dotvec): return (1,1,1)
91    
92            angles = 0
93          tex_scale = 1          tex_scale = 1
94          tex_bias = 0          tex_bias = 0
95          tex_format = [ 2, "HILO_NV", "HILO_NV" ]          tex_format = [ 2, "HILO_NV", "HILO_NV" ]
# Line 136  def init(profile): Line 137  def init(profile):
137          def colmap0(dotvec): return (1,1,1)          def colmap0(dotvec): return (1,1,1)
138          def colmap1(dotvec): return (0,0,0)          def colmap1(dotvec): return (0,0,0)
139    
140            angles = 3
141          tex_scale = 1          tex_scale = 1
142          tex_bias = 0          tex_bias = 0
143          tex_format = [ 4, "RGBA", "RGBA" ]          tex_format = [ 4, "RGBA", "RGBA" ]
# Line 160  def init(profile): Line 162  def init(profile):
162          def colmap0(dotvec): return [.5 + .5 * c for c in dotvec]          def colmap0(dotvec): return [.5 + .5 * c for c in dotvec]
163          def colmap1(dotvec): return [.5 + .25 * c for c in dotvec]          def colmap1(dotvec): return [.5 + .25 * c for c in dotvec]
164    
165            angles = 3
166          tex_scale = .25          tex_scale = .25
167          tex_bias = .75          tex_bias = .75
168          tex_format = [ 4, "RGBA", "RGBA" ]          tex_format = [ 4, "RGBA", "RGBA" ]
# Line 178  def init(profile): Line 181  def init(profile):
181          def colmap0(dotvec): return (1,1,1,1)          def colmap0(dotvec): return (1,1,1,1)
182          def colmap1(dotvec): return (0,0,0,0)          def colmap1(dotvec): return (0,0,0,0)
183                    
184            angles = 0
185          tex_scale = 1          tex_scale = 1
186          tex_bias = 0          tex_bias = 0
187          tex_format = [ 1, "INTENSITY", "LUMINANCE" ]          tex_format = [ 1, "INTENSITY", "LUMINANCE" ]
# Line 186  def init(profile): Line 190  def init(profile):
190    
191    
192      args = ["radius", "2", "ripple_scale", str(ripple_scale),      args = ["radius", "2", "ripple_scale", str(ripple_scale),
193              "scale", str(tex_scale), "bias", str(tex_bias), "eps", ".125"]              "scale", str(tex_scale), "bias", str(tex_bias),
194                "angles", str(angles), "eps", ".125"]
195    
196    
197      tex = getCachedTexture([texsize, texsize, 0] + tex_format +      tex = getCachedTexture([texsize, texsize, 0] + tex_format +
# Line 280  def getIrregu(invert, x0, y0, x1, y1, ou Line 285  def getIrregu(invert, x0, y0, x1, y1, ou
285                           ]                           ]
286                         ]                         ]
287    
288      if outer:      vec = [ 0 for i in range(0, angles) ]
         a = angle * 6 / (2 * pi)  
         while a < 0: a+=3  
         i = int(a) % 3  
         f = a - int(a)  
289    
290          vecs = [ (1,0,0),  (0,0,1),  (0,1,0),  (1,0,0) ]      if angles:
291          vec = lerp(vecs[i], vecs[i+1], f)          if outer:
292      else:              a = angle * (angles / pi)
293          vec = (1,0,0)              while a < 0: a += angles
294                i0 = int(a) % angles
295      dotvec = js(vec)              i1 = (i0 + 1) % angles
296                f = a - int(a)
297                
298                vec[i0] = 1 - f
299                vec[i1] = f
300            else:
301                vec[0] = 1
302    
303            dotvec = js(vec)
304    
305        if not using_shader:
306            # Interpolate outer edge towards inner edge with NV_COMB
307            a = 2**-edgelodbias
308            dotvec = js(vecmul(vec,a) + [1-a]) + " #"
309        
310    
311      cols = [ colmap0(vec),      cols = [ colmap0(vec),
312               colmap1(vec),               colmap1(vec),

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

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