Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/color.py
diff options
context:
space:
mode:
authorerikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0>2007-04-05 23:43:21 (GMT)
committer erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0>2007-04-05 23:43:21 (GMT)
commitb326f156317002b75be9a44865fcc70ec3b12820 (patch)
tree4ae21b4fbbede01762b93635a897e44c35630deb /color.py
parent054e2018bc38ff2fd68bec8d324c3f435dc3dc4f (diff)
version 3 added
git-svn-id: http://mediamods.com/public-svn/camera-activity/Camera.activity@13 574bc980-5f2d-0410-acbc-c8f9f0eb14e0
Diffstat (limited to 'color.py')
-rwxr-xr-xcolor.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/color.py b/color.py
new file mode 100755
index 0000000..44dc014
--- /dev/null
+++ b/color.py
@@ -0,0 +1,32 @@
+class Color:
+
+ def __init__(self, r, g, b, a):
+ self._ro = r
+ self._go = g
+ self._bo = b
+ self._ao = a;
+ self._r = self._ro / 255.0
+ self._g = self._go / 255.0
+ self._b = self._bo / 255.0
+ self._a = self._ao / 255.0
+
+ self._opaque = False
+ if (self._a == 1):
+ self.opaque = True
+
+ rgb_tup = ( self._ro, self._go, self._bo )
+ self._hex = self.rgb_to_hex( rgb_tup )
+
+
+ def rgb_to_hex(self, rgb_tuple):
+ hexcolor = '#%02x%02x%02x' % rgb_tuple
+ # that's it! '%02x' means zero-padded, 2-digit hex values
+ return hexcolor
+
+
+ def hex_to_rgb(color):
+ c = eval('0x' + color[1:])
+ r = (c >> 16) & 0xFF
+ g = (c >> 8) & 0xFF
+ b = c & 0xFF
+ return (r, g, b) \ No newline at end of file