Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- While (R) >= 0:
- R=input("What is the value for Red?")
- G=input("What is the value for Green?")
- B=input("What is the value for Blue?")
- R=eval(R)/255
- G=eval(G)/255
- B=eval(B)/255
- maxval=max(R,G,B)
- minval=min(R,G,B)
- delta=maxval-minval
- print("Which color format would you like to convert to?")
- colorformat = input( "CMY=CMY,CMYK=CMYK,HSV=HSV: " )
- if colorformat == "CMY":
- C = 1 - R
- M = 1 - G
- Y = 1 - B
- print("The CMY values corresponding to ("+str(R)+","+str(G)+","+str(B)+") are ("+str(C)+","+str(M)+","+str(Y)+")")
- if colorformat == "CMYK":
- C = maxval - R
- M = maxval - G
- Y = maxval - B
- K = 1 - maxval
- print("The CYMK values corresponding to ("+str(R)+","+str(G)+","+str(B)+") are ("+str(C)+","+str(M)+","+str(Y)+","+str(K)+")")
- if colorformat == "HSV":
- V = maxval
- S = V
- if V != 0:
- (maxval-minval)/maxval
- else:
- V == 0
- H = S
- if S == 0:
- H == 0
- elif R == maxval:
- H == (G-B)/delta
- elif G == maxval:
- H == 2+(B-R)/delta
- elif B == maxval:
- H == (4+(R-G)/delta)*60
- elif H < 0:
- H == H + 360
- print("The HSV values corresponding to ("+str(R)+","+str(G)+","+str(B)+") are ("+str(H)+","+str(S)+","+str(V)+")")
Add Comment
Please, Sign In to add comment