gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx libcolor/spaces.py libpaper/colors.py l...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx libcolor/spaces.py libpaper/colors.py l...
Date: Tue, 24 Sep 2002 09:09:24 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/09/24 09:09:24

Modified files:
        gfx/libcolor   : spaces.py 
        gfx/libpaper   : colors.py papermill.py params.py 
Added files:
        gfx/libcolor   : __init__.py 
        gfx/libpaper   : __init__.py 

Log message:
        Start making libpaper use real modules

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcolor/__init__.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcolor/spaces.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/__init__.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/colors.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/papermill.py.diff?tr1=1.29&tr2=1.30&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/params.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gzz/gfx/libcolor/spaces.py
diff -c gzz/gfx/libcolor/spaces.py:1.4 gzz/gfx/libcolor/spaces.py:1.5
*** gzz/gfx/libcolor/spaces.py:1.4      Wed Aug 14 06:22:27 2002
--- gzz/gfx/libcolor/spaces.py  Tue Sep 24 09:09:24 2002
***************
*** 1,5 ****
--- 1,7 ----
  # Some color space conversions
  
+ import math
+ 
  def RGBtoXYZ(v):
      mat = [[ 0.412453, 0.35758 , 0.180423],
             [ 0.212671, 0.71516 , 0.072169],
***************
*** 34,40 ****
  def abdiff(a, b):
      u = RGBtoLAB(a)
      v = RGBtoLAB(b)
!     return Math.sqrt((u[1] - v[1])**2 + (u[2] - v[2])**2)
  
  def Ldiff(a, b):
      u = RGBtoLAB(a)
--- 36,42 ----
  def abdiff(a, b):
      u = RGBtoLAB(a)
      v = RGBtoLAB(b)
!     return math.sqrt((u[1] - v[1])**2 + (u[2] - v[2])**2)
  
  def Ldiff(a, b):
      u = RGBtoLAB(a)
***************
*** 72,79 ****
      rgb = [-1]
      L = minL + (maxL - minL) * rnd.nextDouble()
      ang = rnd.nextDouble() * 2 * math.pi
!     a = 100 * Math.cos(ang)
!     b = 100 * Math.sin(ang)
      rgb = LABtoRGB([L,a,b])
      if len(filter((lambda x: x<0 or x>1), rgb)) == 0:
          return rgb
--- 74,81 ----
      rgb = [-1]
      L = minL + (maxL - minL) * rnd.nextDouble()
      ang = rnd.nextDouble() * 2 * math.pi
!     a = 100 * math.cos(ang)
!     b = 100 * math.sin(ang)
      rgb = LABtoRGB([L,a,b])
      if len(filter((lambda x: x<0 or x>1), rgb)) == 0:
          return rgb
Index: gzz/gfx/libpaper/colors.py
diff -c gzz/gfx/libpaper/colors.py:1.5 gzz/gfx/libpaper/colors.py:1.6
*** gzz/gfx/libpaper/colors.py:1.5      Sat Sep 21 07:13:54 2002
--- gzz/gfx/libpaper/colors.py  Tue Sep 24 09:09:24 2002
***************
*** 1,6 ****
--- 1,10 ----
  # Choosing colors and 3-dotproduct factors for papers.
  
+ from gfx.libcolor.spaces import getRandomColor2
+ 
  from math import atan2,pi
+ 
+ import java;
  
  class Colors:
      def _js(self, arg):
Index: gzz/gfx/libpaper/papermill.py
diff -c gzz/gfx/libpaper/papermill.py:1.29 gzz/gfx/libpaper/papermill.py:1.30
*** gzz/gfx/libpaper/papermill.py:1.29  Mon Sep 23 10:39:25 2002
--- gzz/gfx/libpaper/papermill.py       Tue Sep 24 09:09:24 2002
***************
*** 1,7 ****
  dbg = 0
  initialized = 0
  
! execfile("gfx/libcolor/spaces.py")
  
  from gzz.gfx.gl import GL,GLRen,Paper,PaperMill
  import java
--- 1,7 ----
  dbg = 0
  initialized = 0
  
! from gfx.libpaper.colors import Colors
  
  from gzz.gfx.gl import GL,GLRen,Paper,PaperMill
  import java
***************
*** 23,29 ****
      files = [
        "textures.py",
        "texcoords.py",
!       "colors.py",
          "params.py"
        ]
  
--- 23,29 ----
      files = [
        "textures.py",
        "texcoords.py",
!       #"colors.py",
          "params.py"
        ]
  
***************
*** 38,46 ****
--- 38,48 ----
        # otherwise it'll be SLOW.
        if dbg: print "Using NV20 texture shaders"
        files.append("texops_NV2X.py")
+         #from gfx.libpaper.texops_NV2X import *
      else:
        if dbg: print "Using unextended OpenGL texture accesses"
        files.append("texops_STD.py")
+         #from gfx.libpaper.texops_STD import *
  
  
      # Check which combiners to use.
Index: gzz/gfx/libpaper/params.py
diff -c gzz/gfx/libpaper/params.py:1.2 gzz/gfx/libpaper/params.py:1.3
*** gzz/gfx/libpaper/params.py:1.2      Fri Sep 20 10:29:22 2002
--- gzz/gfx/libpaper/params.py  Tue Sep 24 09:09:24 2002
***************
*** 17,31 ****
  
  regseed = RegInt()
  
  class Registry:
      def __init__(self):
!         self.vars = {}
  
      def sub(self, name):
!         return self.get("sub", name, Registry())
  
      def set(self, type, name, val):
          key = (name, type)
          self.vars[key] = val
          return val
  
--- 17,39 ----
  
  regseed = RegInt()
  
+ class RegSub:
+     pass
+ 
+ regsub = RegSub()
+ 
  class Registry:
      def __init__(self):
!         self.vars = {} 
!         self.keys = [] # The access order of keys for printing
  
      def sub(self, name):
!         return self.get(regsub, name, Registry())
  
      def set(self, type, name, val):
          key = (name, type)
+         if not self.vars.has_key(key):
+             self.keys.append(key)
          self.vars[key] = val
          return val
  
***************
*** 33,71 ****
          key = (name, type)
          if not self.vars.has_key(key):
              self.vars[key] = default
              
          return self.vars[key]
  
      def dump(self, prefix = ""):
!         keys = self.vars.keys()
!         keys.sort()
!         for key in keys:
!             print prefix + "." + key[0], key[1], self.vars[key]
!             if key[1] == "sub":
!                 self.vars[key].dump(prefix + "." + key[0])
  
  
  """
  
  from java.util import Random
  
! def getcolor(seed, foo, name):
!     bar = foo.sub(name)
  
!     rng = Random(bar.get(regseed, "seed", seed))
!     r = bar.get(regfloat, "R", rng.nextFloat())
!     g = bar.get(regfloat, "G", rng.nextFloat())
!     b = bar.get(regfloat, "B", rng.nextFloat())
! 
!     return foo.get(regcolor, name, (r,g,b))
  
  
  foo = Registry()
  
  rng = Random()
  
! c =  getcolor(rng.nextInt(), foo, "Color")
! 
  
  foo.dump()
  
--- 41,78 ----
          key = (name, type)
          if not self.vars.has_key(key):
              self.vars[key] = default
+             self.keys.append(key)
              
          return self.vars[key]
  
      def dump(self, prefix = ""):
!         for key in self.keys:
!             if self.vars.has_key(key):
!                 print prefix + key[0], key[1], self.vars[key]
!                 if key[1] == regsub:
!                     self.vars[key].dump(prefix + key[0] + ".")
  
  
  """
  
  from java.util import Random
  
! def getcolor(foo):
!     rng = Random(foo.get(regseed, "seed"))
!     r = foo.get(regfloat, "R", rng.nextFloat())
!     g = foo.get(regfloat, "G", rng.nextFloat())
!     b = foo.get(regfloat, "B", rng.nextFloat())
  
!     return (r,g,b)
  
  
  foo = Registry()
  
  rng = Random()
  
! bar = foo.sub("Color")
! bar.get(regseed, "seed", rng.nextInt())
! c = foo.get(regcolor, "Color", getcolor(bar))
  
  foo.dump()
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]