Color.st
changeset 3005 b8d9132ebbfd
parent 2999 5e9272beef1b
child 3021 5f9fc57177b8
--- a/Color.st	Thu Oct 28 09:06:06 1999 +0200
+++ b/Color.st	Thu Oct 28 09:25:25 1999 +0200
@@ -604,7 +604,7 @@
 !
 
 bgrValue:bgr
-    "return a color from a 24bit bgr value;
+    "return a color from a 24bit BGR value (intentionally not RGB);
      The value is composed of b<<16 + g<<8 + r.
      (this byte-order is sometimes encountered with windows systems (progs)"
 
@@ -621,9 +621,13 @@
     "return a color from blue value;
      the argument green is interpreted as percent (0..100)"
 
-    ^here scaledRed:   0
-          scaledGreen: 0
-          scaledBlue:  (blue * MaxValue // 100)
+    ^ here 
+        scaledRed:0 scaledGreen:0 scaledBlue:(blue * MaxValue // 100)
+
+    "
+     (Color blue:50) inspect
+    "
+
 !
 
 brightness:brightness
@@ -704,7 +708,7 @@
     "
      Color cyan:100 magenta:0 yellow:0 black:0      - cyan    
      Color cyan:100 magenta:0 yellow:0 black:50     - cyan darkened   
-     Color cyan:100 magenta:50 yellow:50 black:0       - cyan darkened   
+     Color cyan:100 magenta:50 yellow:50 black:0    - cyan darkened   
      Color cyan:0 magenta:0 yellow:0 black:100      - black  
     "
 
@@ -753,10 +757,9 @@
     ^ newColor
 
     "
-     |c|
-
-     c := Color dither:0.5 between:Color red and:Color yellow on:Display.
-     c inspect.
+     (Color dither:0.25 between:Color red and:Color yellow on:Display) inspect
+     (Color dither:0.5 between:Color red and:Color yellow on:Display) inspect
+     (Color dither:0.75 between:Color red and:Color yellow on:Display) inspect
     "
 
     "Created: 3.5.1997 / 10:54:32 / cg"
@@ -846,13 +849,17 @@
     "Modified: / 9.1.1998 / 20:48:58 / stefan"
 !
 
-green: green
+green:green
     "return a color from green value;
      the argument green is interpreted as percent (0..100)"
 
-    ^here scaledRed:   0
-          scaledGreen: (green * MaxValue // 100)
-          scaledBlue:  0
+    ^ here 
+        scaledRed:0 scaledGreen:(green * MaxValue // 100) scaledBlue:0
+
+    "
+     (Color green:50) inspect
+    "
+
 !
 
 hue:h light:l saturation:s
@@ -884,8 +891,9 @@
      We hereby only guarantee that the 8 basic colors are supported
      on every device (X uses the Xcolor database, so it supports more
      names - other devices use a builtIn name table containing only the
-     common names) - use with special names (such as 'mediumGoldenRod'
-     is not recommended). Better use: #name:ifIllegal: and provide a fallBack."
+     common names) 
+     - use with special names (such as 'mediumGoldenRod' is not recommended). 
+     Better use: #name:ifIllegal: and provide a fallBack."
 
     ^ self 
         name:colorName 
@@ -952,13 +960,16 @@
     "Modified: 17.1.1997 / 00:06:49 / cg"
 !
 
-red: red
+red:red
     "return a color from red value;
      the argument r is interpreted as percent (0..100)"
 
-    ^here scaledRed:   (red * MaxValue // 100)
-          scaledGreen: 0
-          scaledBlue:  0
+    ^ here 
+        scaledRed:(red * MaxValue // 100) scaledGreen:0 scaledBlue:0
+
+    "
+     (Color red:50) inspect
+    "
 !
 
 red:r green:g blue:b
@@ -997,7 +1008,7 @@
 !
 
 rgbValue:rgb
-    "return a color from a 24bit rgb value;
+    "return a color from a 24bit RGB value;
      The value is composed of r<<16 + g<<8 + b."
 
     |r g b|
@@ -4772,6 +4783,12 @@
 
     ^ aColor deltaFromRed:self red green:self green blue:self blue
 
+    "
+     Color red deltaFrom:(Color blue)  
+     Color red deltaFrom:(Color yellow)  
+     Color red deltaFrom:(Color red:50)  
+    "
+
     "Created: 14.6.1996 / 20:07:22 / cg"
     "Modified: 14.6.1996 / 20:49:32 / cg"
 !
@@ -4783,9 +4800,9 @@
     "
      Q: how should component errors be weighted ?
     "
-    ^ (self red - r) abs
+    ^ ((self red - r) abs
       + (self green - g) abs
-      + (self blue - b) abs.
+      + (self blue - b) abs) rounded.
 
     "Created: 14.6.1996 / 20:03:58 / cg"
     "Modified: 14.6.1996 / 20:20:24 / cg"
@@ -4864,7 +4881,7 @@
 !
 
 isGrayColor
-    "return true, if this color is a gray one -
+    "return true, if this color is a gray one (US version ;-) -
      i.e. red = green = blue"
 
     red ~~ green ifTrue:[^ false].
@@ -4968,6 +4985,6 @@
 !Color class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.148 1999-10-27 13:32:05 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.149 1999-10-28 07:25:25 stefan Exp $'
 ! !
 Color initialize!