gzz-commits
[Top][All Lists]
Advanced

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

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


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx/libpaper colors.py
Date: Tue, 25 Mar 2003 13:48:23 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        03/03/25 13:48:23

Modified files:
        gfx/libpaper   : colors.py 

Log message:
        try to select better solid colors

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/colors.py.diff?tr1=1.21&tr2=1.22&r1=text&r2=text

Patches:
Index: gzz/gfx/libpaper/colors.py
diff -u gzz/gfx/libpaper/colors.py:1.21 gzz/gfx/libpaper/colors.py:1.22
--- gzz/gfx/libpaper/colors.py:1.21     Mon Mar  3 09:09:54 2003
+++ gzz/gfx/libpaper/colors.py  Tue Mar 25 13:48:23 2003
@@ -26,7 +26,7 @@
 from gfx.libcolor.spaces import 
getRandomColor,getRandomColor2,YSTtoRGB,clampSat,LtoY
 from gfx.libcolor.spaces import RGBtoLAB,LABtoRGB,LABclamp
 
-from math import sin,cos,atan2,pi,log
+from math import sin,cos,atan2,pi,log,sqrt
 from random import Random,shuffle
 
 import java
@@ -69,11 +69,18 @@
 
         # Take one half dark colors and one half light colors
         lumrange = 100 - minlum
-        lums = ([minlum + rnd.nextDouble() * lumrange/2
-                 for i in range(0,(colors+1)/2)] +
-                [minlum + (1 + rnd.nextDouble()) * lumrange/2
-                 for i in range((colors+1)/2,colors)]
-                )
+        if colors == 1:
+            # Use the full luminance range for solid color backgrounds
+            x = rnd.nextDouble()
+            # Weight lower luminances more
+            x = (1 - sqrt(1-x))
+            lums = [minlum + x * lumrange]
+        else:
+            lums = ([minlum + rnd.nextDouble() * lumrange/2
+                     for i in range(0,(colors+1)/2)] +
+                    [minlum + (1 + rnd.nextDouble()) * lumrange/2
+                     for i in range((colors+1)/2,colors)]
+                    )
 
         # Sample saturation:
         #  - take the most saturated color 2/3 of the time




reply via email to

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