Skip to content

Instantly share code, notes, and snippets.

@davidhariri
Created May 14, 2015 00:06
Show Gist options
  • Save davidhariri/ba32582129b55ed5b249 to your computer and use it in GitHub Desktop.
Save davidhariri/ba32582129b55ed5b249 to your computer and use it in GitHub Desktop.
default-picture.py
import sys
import colour
import random
import svgwrite
import math
from datetime import datetime
# i redacted most of our colors for testing purposes
palette = [ "#ecc3af", "#ac3f3d", "#fee2cd"]
def makeSkyImage():
c = colour.Color(random.choice(palette))
bg = c.hex
fg = colour.Color(hue=c.hsl[0], saturation=c.hsl[1], luminance=(c.hsl[2]*0.79)).hex
# uncomment the line below to test out a random color for both foreground and background
# fg = colour.Color(random.choice(palette)).hex
size = (100, 100)
d = datetime.utcnow()
h = d.hour + d.minute / 60. + d.second / 3600.
dwg = svgwrite.Drawing(filename=str(int(h))+'.svg', size=size, profile='tiny')
dwg.add(dwg.rect((0, 0), size, fill=bg))
r = size[0]/1.8
tx = r + (r * math.cos((h/24)*(2*math.pi)+(math.pi*0.5)))
ty = r + ((r*0.8) * math.sin((h/24)*(2*math.pi)+(math.pi*0.5))) + 20
dwg.add(dwg.ellipse((tx, ty), (r, r), fill=fg))
dwg.save()
makeSkyImage()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment