[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx demo/color/colors.py libpaper/colors.py
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx demo/color/colors.py libpaper/colors.py |
Date: |
Sun, 29 Sep 2002 04:33:37 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/09/29 04:33:37
Modified files:
gfx/demo/color : colors.py
gfx/libpaper : colors.py
Log message:
Sample hue range from the lognormal distribution
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/color/colors.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/colors.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/color/colors.py
diff -c gzz/gfx/demo/color/colors.py:1.5 gzz/gfx/demo/color/colors.py:1.6
*** gzz/gfx/demo/color/colors.py:1.5 Wed Sep 25 07:28:11 2002
--- gzz/gfx/demo/color/colors.py Sun Sep 29 04:33:37 2002
***************
*** 116,121 ****
--- 116,134 ----
"""))
+ def readcolors():
+ file = open("/etc/X11/rgb.txt", "r")
+ lines = file.readlines()
+ file.close()
+ colors = [ line.split() for line in lines[1:] ]
+
+ hash = {}
+ for rgb in colors:
+ hash[rgb[3]] = (int(rgb[0])/255.,
+ int(rgb[1])/255.,
+ int(rgb[2])/255.)
+ return hash
+
class CIELABScene:
def __init__(self):
self.labhexes = {}
***************
*** 123,128 ****
--- 136,144 ----
def key(self, k):
if k == "v":
self.recolor()
+ if k == "c":
+ self.colors = readcolors().values()
+
def labhex(self, b):
# Bases:
# (1,1,1)
***************
*** 239,245 ****
b = int(round(lab[0] * 16 / 100 - .5))
#print js(col)+"--->"+str(b)+" "+js(lab)
vs.put(getDList("""
! PointSize 6
Begin POINTS
Color 0 0 0
Vertex %s
--- 255,261 ----
b = int(round(lab[0] * 16 / 100 - .5))
#print js(col)+"--->"+str(b)+" "+js(lab)
vs.put(getDList("""
! PointSize 3
Begin POINTS
Color 0 0 0
Vertex %s
***************
*** 258,270 ****
class CIELABScene2:
def __init__(self):
self.angle = None
def key(self, k):
a = self.angle or 0
if k == "+": self.angle = a + 5
if k == "-": self.angle = a - 5
if k == "0": self.angle = None
!
! pass
def scene(self, vs):
putnoc(vs, background((1.0,1.0,1.0)))
--- 274,288 ----
class CIELABScene2:
def __init__(self):
self.angle = None
+ self.colors = None
def key(self, k):
a = self.angle or 0
if k == "+": self.angle = a + 5
if k == "-": self.angle = a - 5
if k == "0": self.angle = None
! if k == "c":
! self.colors = readcolors().values()
!
def scene(self, vs):
putnoc(vs, background((1.0,1.0,1.0)))
***************
*** 280,294 ****
dsiz = 800
n = 16
! for b in range(0,n):
! l = 100 * (b+.5) /n
!
! vs.put(GLRen.createLABSlice(0, l),
! "labslice"+str(b),
! 10, 600, 450, dsiz*.01, dsiz*.01)
! cs = vs.coords.affineCoordsys(0, "foo", 10, 600, 450,
dsiz*.005, 0, 0, dsiz*.005)
vs.map.put(getDList("""
Color 1 1 1
--- 298,314 ----
dsiz = 800
n = 16
! if not self.colors:
! for b in range(0,n):
! l = 100 * (b+.5) /n
!
! vs.put(GLRen.createLABSlice(0, l),
! "labslice"+str(b),
! 10, 600, 450, dsiz*.01, dsiz*.01)
! cs = vs.coords.affineCoordsys(0, 10, 600, 450,
dsiz*.005, 0, 0, dsiz*.005)
+ vs.matcher.add(cs, "foo")
vs.map.put(getDList("""
Color 1 1 1
***************
*** 301,317 ****
"""), cs)
i = 0
! for rgb in [ (1,0,0), (1,.5,0), (1,1,0), (.5,1,0),
(0,1,0), (0,1,.5), (0,1,1), (0,.5,1),
(0,0,1), (.5,0,1), (1,0,1), (1,0,.5) ]:
lab = RGBtoLAB(rgb)
vs.map.put(getDList("""
! Color 0 0 0
PointSize %s
Begin POINTS
Vertex %s %s
End
! """ % (10 - 5*i, lab[1], lab[2])), cs)
i = 1 - i
if self.angle != None:
--- 321,345 ----
"""), cs)
i = 0
! for rgb in self.colors or [
! (1,0,0), (1,.5,0), (1,1,0), (.5,1,0),
(0,1,0), (0,1,.5), (0,1,1), (0,.5,1),
(0,0,1), (.5,0,1), (1,0,1), (1,0,.5) ]:
lab = RGBtoLAB(rgb)
+ if self.colors:
+ size = 8
+ else:
+ size = 10 - 5*i
+ rgb = (0,0,0)
+
vs.map.put(getDList("""
! Color %s %s %s
PointSize %s
Begin POINTS
Vertex %s %s
End
! """ % (rgb[0], rgb[1], rgb[2],
! size, lab[1], lab[2])), cs)
i = 1 - i
if self.angle != None:
Index: gzz/gfx/libpaper/colors.py
diff -c gzz/gfx/libpaper/colors.py:1.10 gzz/gfx/libpaper/colors.py:1.11
*** gzz/gfx/libpaper/colors.py:1.10 Fri Sep 27 10:05:08 2002
--- gzz/gfx/libpaper/colors.py Sun Sep 29 04:33:37 2002
***************
*** 2,11 ****
from gfx.libcolor.spaces import
getRandomColor,getRandomColor2,RGBtoLAB,LABtoRGB,LABclamp
! from math import sin,cos,atan2,pi
! from random import shuffle
- import java;
dbg=0
--- 2,11 ----
from gfx.libcolor.spaces import
getRandomColor,getRandomColor2,RGBtoLAB,LABtoRGB,LABclamp
! from math import sin,cos,atan2,pi,log
! from random import Random,shuffle
!
dbg=0
***************
*** 13,24 ****
def _js(self, arg):
return " ".join([str(a) for a in arg])
def __init__(self, seed):
! rnd = self.rnd = java.util.Random(seed)
! # currently, 4 colors
! colors = 4
minlum = 80
! huerange = (45 + rnd.nextGaussian() * 45) * (pi / 180)
# Note: This color sampling scheme only produces
# palettes with similar colors.
--- 13,28 ----
def _js(self, arg):
return " ".join([str(a) for a in arg])
def __init__(self, seed):
! rnd = self.rnd = Random(seed)
! rnd.nextDouble = rnd.random
! colors = 8
minlum = 80
! #huerange = (45 + rnd.nextGaussian() * 45)
! huerange = rnd.lognormvariate(log(60), .3)
!
! # gnuplot code for plotting huerange distribution:
! # sigma=.4; mu=log(60); plot [0:360] 1 / (x * sqrt(2 * pi *
sigma**2)) * exp(-(log(x)-mu)**2 / (2 * sigma**2))
# Note: This color sampling scheme only produces
# palettes with similar colors.
***************
*** 27,34 ****
# (Note: color complementing should be done in RGB space)
# Sample hues uniformly from the range shifted to a random angle
hue0 = rnd.nextDouble() * 2*pi
! hues = [hue0 + rnd.nextDouble() * huerange for i in range(0,colors)]
# Take one half dark colors and one half light colors
lumrange = 100 - minlum
--- 31,41 ----
# (Note: color complementing should be done in RGB space)
# Sample hues uniformly from the range shifted to a random angle
+ huerange *= pi / 180
hue0 = rnd.nextDouble() * 2*pi
! hues = ([hue0, hue0 + huerange] +
! [hue0 + rnd.nextDouble() * huerange for i in range(2,colors)])
! shuffle(hues, rnd.nextDouble)
# Take one half dark colors and one half light colors
lumrange = 100 - minlum
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gfx demo/color/colors.py libpaper/colors.py,
Janne V. Kujala <=