Created
March 1, 2017 15:08
-
-
Save mrmccormack/41baf72b72c4800dc03afd2838fdf538 to your computer and use it in GitHub Desktop.
IM 415 Python Art with NodeBox
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
# Learning Python Feb 2017 | |
# | |
# __ __ __ __ | |
# | \/ | | \/ | | |
# | \ / |_ __ | \ / | | |
# | |\/| | '__| | |\/| | | |
# | | | | |_ | | | |_ | |
# |_| |_|_(_) |_| |_(_) | |
# http://nodebox.net | |
# IM415 Portfolio | |
# ----------------------------------- | |
def curves(n=40): | |
""" A random path consisting of n curves. | |
""" | |
autoclosepath(False) | |
beginpath(random(WIDTH), random(HEIGHT)) | |
for i in range(n): | |
h1x = random(1000) | |
h1y = random(1000) | |
h2x = random(1000) | |
h2y = random(1000) | |
x = random(0, WIDTH) | |
y = random(0, HEIGHT) | |
curveto(h1x, h1y, h2x, h2y, x, y) | |
return endpath(draw=False) | |
def grow(p, n=80): | |
""" Draw n expanding variations of a path. | |
""" | |
for i in range(n): | |
points = [] | |
for point in p: | |
point.y *= 1.01 | |
point.x /= 1.01 | |
point.ctrl1.x *= 1.01 | |
point.ctrl2.y *= 1.001 | |
points.append(point) | |
drawpath(points) | |
p = points | |
size(1050, 200) | |
# https://en.wikipedia.org/wiki/Bronze_%28color%29 | |
# Mr. M. got color here, had to /100 | |
colormode(CMYK) | |
stroke(.25, .59, .86, 0, 0.2) | |
strokewidth(0.4) | |
nofill() | |
grow(curves()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment