summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-11-22 14:06:10 (GMT)
committerGuido van Rossum <guido@python.org>1991-11-22 14:06:10 (GMT)
commit01ebbb80ab9a4cdbc8acaa646b2f7a1b234215fc (patch)
treebbcb2f242f622a8a36acc6f8c337ad7b4a27b7b5
parenta63f19798d364718d5975a4fd6234ed9272948cd (diff)
downloadcpython-01ebbb80ab9a4cdbc8acaa646b2f7a1b234215fc.zip
cpython-01ebbb80ab9a4cdbc8acaa646b2f7a1b234215fc.tar.gz
cpython-01ebbb80ab9a4cdbc8acaa646b2f7a1b234215fc.tar.bz2
Initial revision
-rwxr-xr-xDemo/sgi/video/colorsys.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Demo/sgi/video/colorsys.py b/Demo/sgi/video/colorsys.py
new file mode 100755
index 0000000..872b533
--- /dev/null
+++ b/Demo/sgi/video/colorsys.py
@@ -0,0 +1,20 @@
+#
+# Module color - do color conversions
+#
+
+def rgb_to_yiq(r,g,b):
+ y = 0.30*r + 0.59*g + 0.11*b
+ i = 0.60*r - 0.28*g - 0.32*b
+ q = 0.21*r - 0.52*g + 0.31*b
+ return (y,i,q)
+def yiq_to_rgb(y,i,q):
+ r = y + 0.948262*i + 0.624013*q
+ g = y - 0.276066*i - 0.639810*q
+ b = y - 1.105450*i + 1.729860*q
+ if r < 0.0: r = 0.0
+ if g < 0.0: g = 0.0
+ if b < 0.0: b = 0.0
+ if r > 1.0: r = 1.0
+ if g > 1.0: g = 1.0
+ if b > 1.0: b = 1.0
+ return (r,g,b)