/[gzz]/gzz/gfx/demo/color/colors.py
ViewVC logotype

Diff of /gzz/gfx/demo/color/colors.py

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

revision 1.7 by jvk, Sun Sep 29 10:56:07 2002 UTC revision 1.8 by jvk, Mon Sep 30 10:18:54 2002 UTC
# Line 2  from __future__ import nested_scopes Line 2  from __future__ import nested_scopes
2    
3  # Look at some colors...  # Look at some colors...
4  import math  import math
5    from math import sin,cos,pi,sqrt
6  import java  import java
7  from java.lang import Math  from java.lang import Math
8    
# Line 451  class PaletteScene: Line 452  class PaletteScene:
452              PopAttrib              PopAttrib
453          """))          """))
454    
455    
456    class HueScene:
457        def key(self, k):
458            pass
459        
460        def scene(self, vs):
461            putnoc(vs, background((0.5,0.5,0.5)))
462    
463            code = """
464                Translate 5 1 0
465            """
466        
467            for L in [5*r for r in range(10,20)]:
468                r,g,b = LABtoRGB((L, 0, 0))
469                code += """
470                    Begin TRIANGLE_FAN
471                    Color %s %s %s
472                    Vertex 0 0
473                """ % (r, g, b)
474    
475                for hue in [d * 10 for d in range(-18,18+1)]:
476    
477                    angle0 = (hue / 180.0) * pi
478                    angle = getangle((hue + 360) % 360 / 360.0)
479                    
480                    r,g,b = LABclamp(LABtoRGB((L, 100 * cos(angle), 100 * sin(angle))))
481                    lab = RGBtoLAB((r,g,b))
482                    radius = sqrt(lab[1]**2 + lab[2]**2) * .015
483                    
484                    x,y = radius * cos(angle0), radius * sin(angle0)
485    
486                    code += """
487                        Color %s %s %s
488                        Vertex %s %s
489                    """ % (r, g, b, x, y)
490    
491                
492                code += """
493                    End
494                    #Translate +2.2 0 0
495                """
496                    
497            vs.put(getDList(code), "foobar", 10, 0, 0, 150, 150);
498            
499                
500    
501    
502  currentScene = CIELABScene()  currentScene = CIELABScene()
503    
504  def globalkey(k):  def globalkey(k):
# Line 467  def globalkey(k): Line 515  def globalkey(k):
515      elif k == "4":      elif k == "4":
516          currentScene = CIELABScene2()          currentScene = CIELABScene2()
517          #AbstractUpdateManager.setNoAnimation()          #AbstractUpdateManager.setNoAnimation()
518        elif k == "5":
519            currentScene = HueScene()
520            #AbstractUpdateManager.setNoAnimation()

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

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