moved #colors: from mappedPalette; use it in #withColors.
--- a/Colormap.st Tue Feb 25 19:00:42 1997 +0100
+++ b/Colormap.st Tue Feb 25 19:04:14 1997 +0100
@@ -91,21 +91,7 @@
"given a sequenceable collection of colors, return a new instance
of myself. Renamed from #fromColors: for ST-80 compatibility."
- |n rV gV bV|
-
- n := aColorArray size.
- rV := ByteArray new:n.
- gV := ByteArray new:n.
- bV := ByteArray new:n.
- 1 to:n do:[:i |
- |clr|
-
- clr := aColorArray at:i.
- rV at:i put:(clr red * 255 / 100) rounded.
- bV at:i put:(clr green * 255 / 100) rounded.
- gV at:i put:(clr blue * 255 / 100) rounded.
- ].
- ^ self new redVector:rV greenVector:gV blueVector:bV
+ ^ self new colors:aColorArray
"
Colormap
@@ -115,7 +101,7 @@
"
"Created: 25.2.1997 / 18:59:09 / cg"
- "Modified: 25.2.1997 / 19:00:35 / cg"
+ "Modified: 25.2.1997 / 19:03:08 / cg"
! !
!Colormap methodsFor:'accessing'!
@@ -172,6 +158,30 @@
^ self asArray
!
+colors:aCollectionOfColors
+ "setup the receiver from colors given in a sequenceable collection of colors"
+
+ |sz "{Class: SmallInteger }"|
+
+ sz := aCollectionOfColors size.
+ redVector := ByteArray new:sz.
+ greenVector := ByteArray new:sz.
+ blueVector := ByteArray new:sz.
+
+ 1 to:sz do:[:i |
+ |clr r g b|
+
+ clr := aCollectionOfColors at:i.
+ clr notNil ifTrue:[
+ redVector at:i put:(clr redByte).
+ greenVector at:i put:(clr greenByte).
+ blueVector at:i put:(clr blueByte).
+ ]
+ ].
+
+ "Modified: 25.2.1997 / 19:02:47 / cg"
+!
+
greenAt:index
"return the green component for some index.
The returned value is scaled from the internal 0.. 255 to
@@ -327,5 +337,5 @@
!Colormap class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Colormap.st,v 1.22 1997-02-25 18:00:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Colormap.st,v 1.23 1997-02-25 18:04:14 cg Exp $'
! !