def getcontext(): ctx = Context() ctx.size(w, h) #ctx.stroke(0,0,0,1) ctx.strokewidth(1) ctx.colormode(HSB) return ctx
def test(): import sys sys.path.insert(0, '../..') from nodebox.graphics import Canvas, Context from math import sin NSApplication.sharedApplication().activateIgnoringOtherApps_(0) w, h = 500, 300 m = Movie("xx3.mov") for i in range(200): print "Frame", i ctx = Context() ctx.size(w, h) ctx.rect(100.0 + sin(i / 10.0) * 100.0, i / 2.0, 100, 100) ctx.text(i, 0, 200) m.add(ctx) m.save()
def test(): import sys sys.path.insert(0, '../..') from nodebox.graphics import Canvas, Context from math import sin NSApplication.sharedApplication().activateIgnoringOtherApps_(0) w, h = 500, 300 m = Movie("xx3.mov") for i in range(200): print "Frame", i ctx = Context() ctx.size(w, h) ctx.rect(100.0+sin(i/10.0)*100.0,i/2.0,100,100) ctx.text(i, 0, 200) m.add(ctx) m.save()
def make_circles(): #to install this, see options 2 and 4 at: #http://nodebox.net/code/index.php/Console . Mac Only! from AppKit import NSApplication NSApplication.sharedApplication().activateIgnoringOtherApps_(0) from nodebox.graphics import Context from nodebox.util import random, choice, grid, files hoods = simplejson.load(file("hoods.json")) max_n = float(max(v[0] for k,v in hoods.iteritems())) for hood, vals in hoods.iteritems(): ctx = Context() colors = ctx.ximport("colors") n = vals[0] a = vals[1] ctx.background(None) maxw = 100 pct = n / max_n d = pct * maxw margin = 2 w = h = d + (margin*2) mid = w/2 ctx.size(maxw+margin*2,maxw+margin*2) ctx.fill(colors.hex("#608902d")) ctx.oval(2,2, d,d) ctx.fill(colors.hex("#E6FA87")) n = str(n) ctx.fontsize(int(24 * pct)) tw = ctx.textwidth(n) th = ctx.textheight(n) ctx.text(n, mid-(tw/2), mid+(th/4)) ctx.save("circles/%s.png" % clean_hood_name(hood)) print clean_hood_name(hood)
def make_circles(): #to install this, see options 2 and 4 at: #http://nodebox.net/code/index.php/Console . Mac Only! from AppKit import NSApplication NSApplication.sharedApplication().activateIgnoringOtherApps_(0) from nodebox.graphics import Context from nodebox.util import random, choice, grid, files hoods = simplejson.load(file("hoods.json")) max_n = float(max(v[0] for k, v in hoods.iteritems())) for hood, vals in hoods.iteritems(): ctx = Context() colors = ctx.ximport("colors") n = vals[0] a = vals[1] ctx.background(None) maxw = 100 pct = n / max_n d = pct * maxw margin = 2 w = h = d + (margin * 2) mid = w / 2 ctx.size(maxw + margin * 2, maxw + margin * 2) ctx.fill(colors.hex("#608902d")) ctx.oval(2, 2, d, d) ctx.fill(colors.hex("#E6FA87")) n = str(n) ctx.fontsize(int(24 * pct)) tw = ctx.textwidth(n) th = ctx.textheight(n) ctx.text(n, mid - (tw / 2), mid + (th / 4)) ctx.save("circles/%s.png" % clean_hood_name(hood)) print clean_hood_name(hood)