--- a/ColorValue.st Sat Jun 08 12:43:12 1996 +0200
+++ b/ColorValue.st Wed Jun 12 14:17:14 1996 +0200
@@ -49,7 +49,7 @@
"return a grey color.
The grey value is given in 0..1 instead of percent"
- ^ Color gray:(grey * 100)
+ ^ self scaledGray:(grey * MaxValue) rounded
"
ColorValue brightness:0.5
@@ -79,7 +79,7 @@
The hue, saturation and brightness values are given in 0..1 instead of
degrees / percent"
- ^ Color hue:hue*360 light:light*100 saturation:sat*100
+ ^ self hue:hue*360 light:light*100 saturation:sat*100
"
ColorValue hue:0 saturation:1 brightness:0.5
@@ -90,32 +90,39 @@
"return a color from red, green and blue values.
The arguments, r, g and b must be in the range (0..1)"
- ^ Color red:r*100 green:g*100 blue:b*100
+ ^ self
+ scaledRed:(r * MaxValue) rounded
+ scaledGreen:(g * MaxValue) rounded
+ scaledBlue:(b * MaxValue) rounded
"
ColorValue red:0 green:1 blue:0
+ ColorValue red:0 green:0.5 blue:0
"
+! !
+
+!ColorValue methodsFor:'accessing'!
+
+red
+ "return the red component in 0..1"
+
+ ^ red / MaxValue
!
-scaledRed:r scaledGreen:g scaledBlue:b
- "ST-80 compatibility.
- Return a color from r, g and b values;
- the arguments, r, g and b are interpreted as 13bit
- direct value (0..8191); 0/0/0 is black, 8191/8191/8191 is white."
+green
+ "return the green component in 0..1"
- ^ Color red:(r * 100 / 8191)
- green:(g * 100 / 8191)
- blue:(b * 100 / 8191)
+ ^ green / MaxValue
+!
- "
- ColorValue scaledRed:8191 scaledGreen:8191 scaledBlue:8191
- ColorValue scaledRed:0 scaledGreen:0 scaledBlue:0
- ColorValue scaledRed:4092 scaledGreen:4092 scaledBlue:4092
- "
+blue
+ "return the blue component in 0..1"
+
+ ^ blue / MaxValue
! !
!ColorValue class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/ColorValue.st,v 1.10 1996-05-28 19:04:48 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/ColorValue.st,v 1.11 1996-06-12 12:17:14 cg Exp $'
! !