added literalEncodings
authorClaus Gittinger <cg@exept.de>
Wed, 22 Jan 1997 04:19:07 +0100
changeset 378 3924b37b0ea4
parent 377 afe504923e5b
child 379 62b71a8294a3
added literalEncodings
ClrValue.st
ColorValue.st
--- a/ClrValue.st	Tue Jan 21 15:24:37 1997 +0100
+++ b/ClrValue.st	Wed Jan 22 04:19:07 1997 +0100
@@ -147,8 +147,48 @@
     "Created: 11.6.1996 / 17:17:57 / cg"
 ! !
 
+!ColorValue methodsFor:'converting'!
+
+fromLiteralArrayEncoding:encoding
+    "read my values from an encoding.
+     The encoding is supposed to be of the form: 
+        (#ColorValue scaledRed scaledGreen scaledBlue)
+     This is the reverse operation to #literalArrayEncoding."
+
+    red := (encoding at:2).
+    green := (encoding at:3).
+    blue := (encoding at:4).
+
+    "
+      ColorValue new fromLiteralArrayEncoding:#(#Color 7700 7700 7700)
+    "
+
+    "Created: 22.1.1997 / 04:18:50 / cg"
+!
+
+literalArrayEncoding
+    "encode myself as an array, from which a copy of the receiver
+     can be reconstructed with #decodeAsLiteralArray.
+     The encoding is: 
+        (#ColorValue scaledRed scaledGreen scaledBlue)
+    "
+
+    ^ Array
+        with:self class name asSymbol
+        with:(self scaledRed)
+        with:(self scaledGreen)
+        with:(self scaledBlue)
+
+    "
+      ColorValue new fromLiteralArrayEncoding:#(#Color 50 25 25)
+      (ColorValue red:0.5 green:0.25 blue:1.0) literalArrayEncoding 
+    "
+
+    "Modified: 22.1.1997 / 04:17:59 / cg"
+! !
+
 !ColorValue class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/Attic/ClrValue.st,v 1.12 1996-06-12 12:24:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/Attic/ClrValue.st,v 1.13 1997-01-22 03:19:07 cg Exp $'
 ! !
--- a/ColorValue.st	Tue Jan 21 15:24:37 1997 +0100
+++ b/ColorValue.st	Wed Jan 22 04:19:07 1997 +0100
@@ -147,8 +147,48 @@
     "Created: 11.6.1996 / 17:17:57 / cg"
 ! !
 
+!ColorValue methodsFor:'converting'!
+
+fromLiteralArrayEncoding:encoding
+    "read my values from an encoding.
+     The encoding is supposed to be of the form: 
+        (#ColorValue scaledRed scaledGreen scaledBlue)
+     This is the reverse operation to #literalArrayEncoding."
+
+    red := (encoding at:2).
+    green := (encoding at:3).
+    blue := (encoding at:4).
+
+    "
+      ColorValue new fromLiteralArrayEncoding:#(#Color 7700 7700 7700)
+    "
+
+    "Created: 22.1.1997 / 04:18:50 / cg"
+!
+
+literalArrayEncoding
+    "encode myself as an array, from which a copy of the receiver
+     can be reconstructed with #decodeAsLiteralArray.
+     The encoding is: 
+        (#ColorValue scaledRed scaledGreen scaledBlue)
+    "
+
+    ^ Array
+        with:self class name asSymbol
+        with:(self scaledRed)
+        with:(self scaledGreen)
+        with:(self scaledBlue)
+
+    "
+      ColorValue new fromLiteralArrayEncoding:#(#Color 50 25 25)
+      (ColorValue red:0.5 green:0.25 blue:1.0) literalArrayEncoding 
+    "
+
+    "Modified: 22.1.1997 / 04:17:59 / cg"
+! !
+
 !ColorValue class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/ColorValue.st,v 1.12 1996-06-12 12:24:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ColorValue.st,v 1.13 1997-01-22 03:19:07 cg Exp $'
 ! !