Skip to content

Instantly share code, notes, and snippets.

@ondrejzacha
Created February 27, 2019 22:29
Show Gist options
  • Save ondrejzacha/f49a5626afcd55e5d5906a5993ca9426 to your computer and use it in GitHub Desktop.
Save ondrejzacha/f49a5626afcd55e5d5906a5993ca9426 to your computer and use it in GitHub Desktop.
noisy circles 1
WIDTH = 1200
HEIGHT = 800
NO_POINTS = 7
def setup():
# size(WIDTH, HEIGHT)
fullScreen()
frameRate(15)
# noLoop()
background(255)
def draw():
# background(255)
stroke(0, 10)
for r in range(50, 500, 50):
pseudo_circle(radius=r, circle_center=(width/2, height/2), no_points=NO_POINTS)
# TODO:
# - kontinuita v 2pi
# - hezci parametry pro noise()
def mousePressed():
background(255)
def pseudo_circle(radius, circle_center, no_points=8):
xs = []
ys = []
noise_values = []
for i in range(no_points + 3):
if i < no_points:
angle = frameCount/TWO_PI + TWO_PI * i/(no_points * 1.) * map(noise(i + 0.01*frameCount), 0, 1, 0.9, 1.1)
radius_noise = map(noise(i + 0.01*frameCount), 0, 1, 0.1, 2)
x_ = circle_center[0] + cos(angle) * radius * radius_noise
y_ = circle_center[1] + sin(angle) * radius * radius_noise
else:
x_ = xs[i % no_points]
y_ = ys[i % no_points]
# ellipse(x_, y_, 10, 10)
xs += [x_]
ys += [y_]
xys = zip(xs, ys)
line_sequence(*xys)
def line_sequence(*args):
noFill()
beginShape()
for x in args:
curveVertex(*x)
endShape()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment