Color.st
changeset 3396 18f99e9fc5ec
parent 3324 a4244f890bde
child 3399 02a4018f9549
--- a/Color.st	Mon Jan 08 14:42:38 2001 +0100
+++ b/Color.st	Mon Jan 08 18:33:01 2001 +0100
@@ -1200,24 +1200,6 @@
     "Note: By convention, brightness is abbreviated 'v' to to avoid confusion with blue."
 
     ^ self hue:hue light:(brightness*50) saturation:(saturation*100)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 !
 
 pixelScreenForDepth: depth
@@ -1250,6 +1232,32 @@
     ^ here scaledRed:(redFraction * MaxValue) rounded
            scaledGreen:(greenFraction * MaxValue) rounded
            scaledBlue:(blueFraction * MaxValue) rounded
+!
+
+showColors: colorList
+        "Display the given collection of colors across the top of the Display."
+
+        | w r |
+        w _ Display width // colorList size.
+        r _ 0@0 extent: w@((w min: 30) max: 10).
+        colorList do: [:c |
+                Display fill: r fillColor: c.
+                r _ r translateBy: w@0].
+!
+
+wheel: thisMany
+    "Return a collection of thisMany colors evenly spaced around the color wheel."
+    "Color showColors: (Color wheel: 12)"
+
+    ^ Color wheel: thisMany saturation: 0.9 brightness: 0.7
+!
+
+wheel: thisMany saturation: s brightness: v
+    "Return a collection of thisMany colors evenly spaced around the color wheel, all of the given saturation and brightness."
+    "Color showColors: (Color wheel: 12 saturation: 0.4 brightness: 1.0)"
+    "Color showColors: (Color wheel: 12 saturation: 0.8 brightness: 0.5)"
+
+    ^ (Color h: 0.0 s: s v: v) wheel: thisMany
 ! !
 
 !Color class methodsFor:'Signal constants'!
@@ -3513,6 +3521,10 @@
 
 !
 
+colorForInsets
+    ^ self
+!
+
 darker
     "return a new color, which is darker than the receiver.
      Almost the same as darkened for Squeak compatibility."
@@ -3575,7 +3587,8 @@
 !
 
 newTileMorphRepresentative
-	^ ColorTileMorph new colorSwatchColor: self!
+	^ ColorTileMorph new colorSwatchColor: self
+!
 
 scaledPixelValue32
     ^ (self redByte bitShift:16)
@@ -3627,6 +3640,22 @@
     "
 
     "Modified: 11.6.1996 / 18:10:49 / cg"
+!
+
+wheel:thisMany
+    "An array of thisMany colors around the color wheel starting at self and ending all the way around the hue space just before self.  Array is of length thisMany.  Very useful for displaying color based on a variable in your program.  "
+
+    | sat bri hue step c |
+
+    thisMany = 1 ifTrue: [^ Array with: self].
+    sat := self saturation / 100.
+    bri := self brightness.
+    hue := self hue.
+    step := 360.0 / thisMany.
+    ^ (1 to: thisMany) collect: [:num |
+            c := Color h: hue s: sat v: bri.  "hue is taken mod 360"
+            hue := hue + step.
+            c].
 ! !
 
 !Color methodsFor:'accessing'!
@@ -5128,6 +5157,6 @@
 !Color class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.161 2000-09-30 15:32:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.162 2001-01-08 17:32:28 cg Exp $'
 ! !
 Color initialize!