Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import colorsys
- from PIL import Image, ImageDraw
- pi = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]
- image_height = 40
- image_width = len(pi) * 10
- img = Image.new("RGB", (image_width, image_height))
- draw = ImageDraw.Draw(img)
- def getColor(val):
- c = colorsys.hsv_to_rgb(val / 10, 1, 1)
- return ( int(c[0] * 256), int(c[1] * 256), int(c[2] * 256) )
- for i in range(len(pi)):
- draw.rectangle([i * 10, 0, (i * 10) + 10, image_height], outline=getColor(pi[i]), fill=getColor(pi[i]))
- img.save("picolour.png")
Add Comment
Please, Sign In to add comment