Skip to content

Instantly share code, notes, and snippets.

@serhei
Last active August 29, 2015 19:05
Show Gist options
  • Save serhei/33319 to your computer and use it in GitHub Desktop.
Save serhei/33319 to your computer and use it in GitHub Desktop.
fairly hideous kuler-based nodebox desktop background (random bubbles)
# A quick desktop background thing using Nodebox and Kuler.
# Requires the Nodebox 'web' plugin.
size (1680, 1050)
gridSize = 10
# Color Scheme taken from Kuler - "Aspirin C"
ximport ("web")
colors, themes = [], web.kuler.search_by_id (251864)
for r, g, b in themes[0]:
colors += [color (r, g, b)]
# Cocoa drop shadow stuff, from the Nodebox tutorial
from AppKit import NSShadow, NSColor
from nodebox.graphics import Grob
class shadow(Grob):
def __init__(self, x=10, y=10, alpha=0.25, blur=4.0):
Grob.__init__(self, _ctx)
self._shadow = NSShadow.alloc().init()
self._shadow.setShadowOffset_((x, -y))
self._shadow.setShadowColor_(color(0, 0, 0, alpha)._rgb)
self._shadow.setShadowBlurRadius_(blur)
self.draw()
def _draw(self):
self._shadow.set()
def noshadow():
shadow(alpha=0)
shadow (x = 25, y = 25, blur = 10.0)
# Rough Grid, adapted from the Nodebox tutorial
for x, y in grid(WIDTH/gridSize, HEIGHT/gridSize, gridSize, gridSize):
s = random()*gridSize
fill(choice (colors))
oval(x, y, s, s)
deltaX = (random()-0.5)*100
deltaY = (random()-0.5)*100
deltaS = (random()-0.5)*100
fill(choice (colors))
oval (x + deltaX, y + deltaY, s + deltaS, s + deltaS)
# A semitransparent shelf for your desktop icons, if desired
# fill (0, 0.5)
# rect (1680-500, 0, 500, 1050)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment