aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-08-14 13:31:21 +0200
committerKevin Chabowski <kevin@kch42.de>2013-08-14 13:31:21 +0200
commitbc7a122e09b9d69858f24e34b5cdb658d7e88307 (patch)
tree9ca2905b1091b685ac3820b03b3aa0b2ed0ee679
parent85f15dee8b37ee1c813723aa47f2cf3c93766e21 (diff)
downloadkagus-bc7a122e09b9d69858f24e34b5cdb658d7e88307.tar.gz
kagus-bc7a122e09b9d69858f24e34b5cdb658d7e88307.tar.bz2
kagus-bc7a122e09b9d69858f24e34b5cdb658d7e88307.zip
Added RGB0x, a simple image/color implementation.
-rw-r--r--rgb.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/rgb.go b/rgb.go
new file mode 100644
index 0000000..a485e10
--- /dev/null
+++ b/rgb.go
@@ -0,0 +1,21 @@
+package kagus
+
+import (
+ "fmt"
+)
+
+// RGB0x is an image/color implementation that allows you to write 24-Bit RGB colors using number literals, usually using the notation 0xRRGGBB
+type RGB0x uint32
+
+func (rgb RGB0x) String() string {
+ return fmt.Sprintf("#%06x", rgb)
+}
+
+func (_rgb RGB0x) RGBA() (r, g, b, a uint32) {
+ rgb := uint32(_rgb)
+ r = (rgb & 0xff0000) >> 8
+ g = rgb & 0xff00
+ b = (rgb & 0xff) << 8
+ a = 0xffff
+ return
+}