Skip to content

Instantly share code, notes, and snippets.

@devdsp
Created November 27, 2013 03:27
Show Gist options
  • Save devdsp/7670253 to your computer and use it in GitHub Desktop.
Save devdsp/7670253 to your computer and use it in GitHub Desktop.
Colour Palette generator using PythonMagick
#!/usr/bin/env python
from PythonMagick import Image, Color
from math import atan2, pi, pow,sqrt
img = Image('128x128', 'white')
xo = img.columns() / 2
yo = img.rows() / 2
for x in range(img.columns()):
for y in range(img.rows()):
h = (atan2( - (y - yo), x - xo) /(2*pi))*360
l = (sqrt( pow(x-xo,2) + pow(y-yo,2)) / xo )*255
c = Color('hsl(%i,255,%i)' %(h,l))
img.pixelColor(x,y,c)
img.write("palette.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment