Skip to content

Instantly share code, notes, and snippets.

@ondrejzacha
Created March 3, 2019 19:24
Show Gist options
  • Save ondrejzacha/5cfb5c78c61a3b474bae131bc7c79e1b to your computer and use it in GitHub Desktop.
Save ondrejzacha/5cfb5c78c61a3b474bae131bc7c79e1b to your computer and use it in GitHub Desktop.
NO_POINTS = 7
def setup():
fullScreen()
frameRate(15)
background(0)
# strokeWeight()
def draw():
background(0)
stroke(255)
for r in range(25, 800, 25):
stroke(255, 155- r * 155/800)
pseudo_circle(radius=r,
circle_center=(width/2, height/2),
no_points=NO_POINTS,
offset=r*2)
def mousePressed():
background(0)
def pseudo_circle(radius, circle_center, no_points=8, offset=0):
xs = []
ys = []
noise_values = []
for i in range(no_points + 3):
if i < no_points:
angle = 0.1 * frameCount / TWO_PI + \
TWO_PI * i / (no_points * 1.) * map(noise(i + 0.01*frameCount), 0, 1, 0.9, 1.1) + \
0.05 * offset/TWO_PI
radius_noise = map(noise(i/9 + 0.01*frameCount + offset), 0, 1, 0.8, 1.2)
x_ = circle_center[0] + cos(angle) * radius * radius_noise
y_ = circle_center[1] + sin(angle) * radius * radius_noise
else:
# these are necessary to finish the shape
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