--- a/Color.st Fri Feb 17 12:36:50 2017 +0100
+++ b/Color.st Fri Feb 17 12:51:00 2017 +0100
@@ -996,6 +996,72 @@
!
+htmlName:colorName
+ "see https://en.wikipedia.org/wiki/Web-safe#HTML_color_names
+ The web defines 16 standard color names, which are returned here.
+ Attention:
+ these are not the same colors as those built into X-servers;
+ eg. (Color name:'green') returns a bright green,
+ whereas (Color htmlName:'green') returns a dark green, and 'lime' would be the X-green.
+ Sigh"
+
+ ^ self
+ htmlName:colorName
+ ifIllegal:[
+ InvalidColorNameSignal
+ raiseRequestWith:colorName errorString:' : ' , colorName
+ ]
+
+ "
+ Color htmlName:'lime'
+
+ Color htmlName:'green'
+ Color name:'green'
+ "
+
+ "Created: / 17-02-2017 / 12:41:17 / cg"
+!
+
+htmlName:colorName ifIllegal:errorBlock
+ "see https://en.wikipedia.org/wiki/Web-safe#HTML_color_names
+ The web defines 16 standard color names, which are returned here.
+ If aString is not a valid color name,
+ return the result from evaluating errorBlock.
+ Attention:
+ these are not the same colors as those built into X-servers;
+ eg. (Color name:'green') returns a bright green,
+ whereas (Color htmlName:'green') returns a dark green, and 'lime' would be the X-green.
+ Sigh"
+
+ |nameLowercase|
+
+ nameLowercase := colorName asLowercase.
+ ^ #(
+ ('silver' 16rC0C0C0)
+ ('maroon' 16r800000)
+ ('olive' 16r808000)
+ ('lime' 16r00FF00)
+ ('green' 16r008000)
+ ('aqua' 16r00FFFF)
+ ('teal' 16r008080)
+ ('navy' 16r000080)
+ ('fuchsia' 16rFF00FF)
+ ('purple' 16r800080)
+ )
+ detect:[:e | e first = nameLowercase]
+ thenCompute:[:e | self rgbValue:(e second)]
+ ifNone:[ self name:colorName ifIllegal:errorBlock ]
+
+ "
+ Color htmlName:'lime'
+
+ Color htmlName:'green'
+ Color name:'green'
+ "
+
+ "Created: / 17-02-2017 / 12:42:01 / cg"
+!
+
hue:h light:l saturation:s
"return a color from hue, light and saturation values.
Hue is in degrees (0..360); light and saturation are