#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Fri, 03 Feb 2017 11:32:11 +0100
changeset 7830 fa41edb7876a
parent 7829 12f0d02f567f
child 7831 460d842964af
#FEATURE by cg class: Color added: #rgbBytes
Color.st
--- a/Color.st	Thu Feb 02 21:15:21 2017 +0100
+++ b/Color.st	Fri Feb 03 11:32:11 2017 +0100
@@ -4313,6 +4313,30 @@
     "Modified: / 26.7.1998 / 12:31:22 / cg"
 !
 
+rgbBytes
+    "return the rgb byteValues as a 3-byte byteArray #[red green blue]"
+
+    |r "{ Class: SmallInteger }"
+     g "{ Class: SmallInteger }"
+     b "{ Class: SmallInteger }"|
+
+    r := red * 255 // MaxValue.
+    g := green * 255 // MaxValue.
+    b := blue * 255 // MaxValue.
+    ^ ByteArray with:r with:g with:b
+
+    "
+     Color red rgbBytes
+     Color blue rgbBytes
+     Color green rgbBytes
+     Color black rgbBytes
+     Color grey rgbBytes
+     Color white rgbBytes
+    "
+
+    "Created: / 03-02-2017 / 11:31:24 / cg"
+!
+
 rgbValue
     "return the rgb byteValues packed into a 24bit integer;
      The returned value is composed of r<<16 + g<<8 + b."