Guest User

Untitled

a guest
Jul 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. While (R) >= 0:
  2.     R=input("What is the value for Red?")
  3. G=input("What is the value for Green?")
  4. B=input("What is the value for Blue?")
  5.  
  6. R=eval(R)/255
  7. G=eval(G)/255
  8. B=eval(B)/255
  9.  
  10. maxval=max(R,G,B)
  11. minval=min(R,G,B)
  12. delta=maxval-minval
  13.  
  14. print("Which color format would you like to convert to?")
  15. colorformat = input( "CMY=CMY,CMYK=CMYK,HSV=HSV: " )
  16.  
  17. if colorformat == "CMY":
  18.     C = 1 - R
  19.     M = 1 - G
  20.     Y = 1 - B
  21.     print("The CMY values corresponding to ("+str(R)+","+str(G)+","+str(B)+") are ("+str(C)+","+str(M)+","+str(Y)+")")
  22.  
  23. if colorformat == "CMYK":
  24.     C = maxval - R
  25.     M = maxval - G
  26.     Y = maxval - B
  27.     K = 1 - maxval
  28.     print("The CYMK values corresponding to ("+str(R)+","+str(G)+","+str(B)+") are ("+str(C)+","+str(M)+","+str(Y)+","+str(K)+")")
  29.  
  30. if colorformat == "HSV":
  31.     V = maxval
  32.     S = V
  33.     if V != 0:
  34.         (maxval-minval)/maxval
  35.     else:
  36.         V == 0
  37.     H = S
  38.     if S == 0:
  39.         H == 0
  40.     elif R == maxval:
  41.         H == (G-B)/delta
  42.     elif G == maxval:
  43.         H == 2+(B-R)/delta
  44.     elif B == maxval:
  45.         H == (4+(R-G)/delta)*60
  46.     elif H < 0:
  47.         H == H + 360
  48.     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