Advertisement
kpvw

ColourProgram

Jul 27th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. import colorsys
  2.  
  3. def main():
  4.   colours = []
  5.   while True:
  6.     inp = raw_input()
  7.     if inp == 'q':
  8.       break
  9.     rgb = ()
  10.     try:
  11.       rgb = tuple(map(float, inp.split(" ")))
  12.     except ValueError:
  13.       continue
  14.     colours.append(rgb)
  15.   colours.sort(key=lambda rgb: colorsys.rgb_to_hsv(*rgb))
  16.   for (r, g, b) in colours:
  17.     print('{} {} {}'.format(int(r), int(g), int(b)))
  18.  
  19. if __name__ == '__main__':
  20.   main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement