Skip to content

Instantly share code, notes, and snippets.

@fdb
Created April 14, 2016 11:55
Show Gist options
  • Save fdb/15ae20a78da6d75e2fd68630f52505c8 to your computer and use it in GitHub Desktop.
Save fdb/15ae20a78da6d75e2fd68630f52505c8 to your computer and use it in GitHub Desktop.
NodeBox 1 random letter script
# NodeBox 1 script that generates a composition of random letters.
# Download NodeBox 1 at https://www.nodebox.net/download/
size(800, 400)
from random import choice, uniform, seed
seed(52)
colors = [[0, 0, 0], [1, 0, 0], [1, 1, 1]]
def comp(x, y, w, h):
push()
p = rect(x, y, w, h, draw=False)
beginclip(p)
font("Helvetica-Bold")
for i in range(6):
sz = random(100, 500)
fontsize(sz)
rotate(random(8) * 45)
fill(*choice(colors))
text("B", x + random(w), y + random(h) + sz / 2, width=0)
endclip()
pop()
nofill()
stroke(0)
strokewidth(0.5)
rect(x, y ,w , h)
for x, y in grid(4, 2, 200, 200):
comp(x, y, 200, 200)
@fdb
Copy link
Author

fdb commented Apr 14, 2016

Screenshot:

random-letter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment