Colormap.st
changeset 1435 b6c31a44424a
parent 1378 a83a3522a199
child 2448 89c338d3412e
--- a/Colormap.st	Thu Mar 06 15:37:12 1997 +0100
+++ b/Colormap.st	Thu Mar 06 15:45:51 1997 +0100
@@ -316,6 +316,27 @@
     "Modified: 2.5.1996 / 12:46:07 / cg"
 ! !
 
+!Colormap methodsFor:'queries'!
+
+indexOfPaintNearest: color
+    |minDistance minIndex dist
+     sz "{ Class: SmallInteger }"|
+
+    minDistance := (self at:1) deltaFrom:color.
+    minIndex := 1.
+    sz := self size.
+    2 to:sz do:[:idx |
+        dist := (self at:idx) deltaFrom:color.
+        dist < minDistance ifTrue:[
+            minDistance := dist.
+            minIndex := idx.
+        ]
+    ].
+    ^ minIndex
+
+    "Created: 6.3.1997 / 15:45:39 / cg"
+! !
+
 !Colormap methodsFor:'storing'!
 
 storeOn:aStream
@@ -337,5 +358,5 @@
 !Colormap class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Colormap.st,v 1.23 1997-02-25 18:04:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Colormap.st,v 1.24 1997-03-06 14:45:51 cg Exp $'
 ! !