Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a63f197 commit 01ebbb8Copy full SHA for 01ebbb8
1 file changed
Demo/sgi/video/colorsys.py
@@ -0,0 +1,20 @@
1
+#
2
+# Module color - do color conversions
3
4
+
5
+def rgb_to_yiq(r,g,b):
6
+ y = 0.30*r + 0.59*g + 0.11*b
7
+ i = 0.60*r - 0.28*g - 0.32*b
8
+ q = 0.21*r - 0.52*g + 0.31*b
9
+ return (y,i,q)
10
+def yiq_to_rgb(y,i,q):
11
+ r = y + 0.948262*i + 0.624013*q
12
+ g = y - 0.276066*i - 0.639810*q
13
+ b = y - 1.105450*i + 1.729860*q
14
+ if r < 0.0: r = 0.0
15
+ if g < 0.0: g = 0.0
16
+ if b < 0.0: b = 0.0
17
+ if r > 1.0: r = 1.0
18
+ if g > 1.0: g = 1.0
19
+ if b > 1.0: b = 1.0
20
+ return (r,g,b)
0 commit comments