Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01ebbb8

Browse files
committed
Initial revision
1 parent a63f197 commit 01ebbb8

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Demo/sgi/video/colorsys.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)