Guest User

Untitled

a guest
Mar 23rd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import colorsys
  2. from PIL import Image, ImageDraw
  3.  
  4. pi = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]
  5.  
  6. image_height = 40
  7. image_width = len(pi) * 10
  8.  
  9. img = Image.new("RGB", (image_width, image_height))
  10.  
  11. draw = ImageDraw.Draw(img)
  12.  
  13.  
  14. def getColor(val):
  15. c = colorsys.hsv_to_rgb(val / 10, 1, 1)
  16. return ( int(c[0] * 256), int(c[1] * 256), int(c[2] * 256) )
  17.  
  18.  
  19. for i in range(len(pi)):
  20. draw.rectangle([i * 10, 0, (i * 10) + 10, image_height], outline=getColor(pi[i]), fill=getColor(pi[i]))
  21.  
  22. img.save("picolour.png")
Add Comment
Please, Sign In to add comment