Add Color >> name jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 20 May 2020 13:36:34 +0100
branchjv
changeset 9044 02110132774b
parent 9025 c491c7d396cd
child 9045 afd775b8fefd
Add Color >> name ...and inverse of `Color name: 'ref'`
Color.st
--- a/Color.st	Fri Jun 07 19:56:22 2019 +0100
+++ b/Color.st	Wed May 20 13:36:34 2020 +0100
@@ -1309,6 +1309,7 @@
     "Modified: 13.5.1996 / 12:41:53 / cg"
 ! !
 
+
 !Color class methodsFor:'Compatibility-Squeak'!
 
 colorPaletteForDepth: depth extent: chartExtent
@@ -3809,6 +3810,7 @@
     "Modified: 11.7.1996 / 18:20:14 / cg"
 ! !
 
+
 !Color methodsFor:'Compatibility-ST80'!
 
 asDevicePaintOn:aDevice
@@ -3945,10 +3947,6 @@
     "Modified: 11.6.1996 / 18:10:49 / cg"
 !
 
-newTileMorphRepresentative
-	^ ColorTileMorph new colorSwatchColor: self
-!
-
 privateBlue
     "Squeak compatibility:
      return the blue components value mapped to 0..MaxValue"
@@ -4247,6 +4245,21 @@
     "Created: 11.6.1996 / 18:30:11 / cg"
 !
 
+name
+    "Return the name of the color or nil, if the color has no standard name"
+
+    StandardColorValues keysAndValuesDo:[ :name :rgb | 
+        (red = rgb first and:[green = rgb second and:[blue = rgb third]]) ifTrue:[ ^ name ]
+    ].
+    ^ nil
+
+    "
+    Color cyan name    
+    "
+
+    "Created: / 20-05-2020 / 13:26:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 privateAlpha
     "return the internal alpha value (0..255),
      where 0 is completely transparent and 255 is completely opaque"
@@ -5708,6 +5721,11 @@
 
 version_CVS
     ^ '$Header$'
+!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
 ! !