Created
November 27, 2013 03:27
-
-
Save devdsp/7670253 to your computer and use it in GitHub Desktop.
Colour Palette generator using PythonMagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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