Skip to content

Instantly share code, notes, and snippets.

@lunhg
Forked from jahpd/BezierSimples.coffee
Last active July 6, 2017 15:46
Show Gist options
  • Save lunhg/b387a7ee0a7c157432bb4928aeeb6619 to your computer and use it in GitHub Desktop.
Save lunhg/b387a7ee0a7c157432bb4928aeeb6619 to your computer and use it in GitHub Desktop.
n = 19
points = {x:[],y:[]} for i in [0..n-1]
update = (a, fn) ->
for _n in [0..a.length-1]
for key,val of a[_n]
fn(_n,key,val)
@text a[_n], 10, (_n+1)*(n/@width)
callback = (n, k, v) ->
v = @random (if k is 'x' then @width else (if k is 'y' then @height))
@setup = -> update points, callback
@draw = ->
@background 0
@noFill()
for i in [0..points.length-1]
@stroke @random 255, @random 255, @random 255
@bezier(points[i].x[0], points[i].y[0], points[i].x[1], points[i].y[1],points[i].x[2],points[i].y[2],points[i].x[3],points[i].y[3])
update points, callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment