boa-0
2012. 05. 22.

"양 한 마리를 그려줘."

"..."

"아냐 이건 모자... 아니 아니, 보아뱀이잖아!"

```p5 = processing
traces = []
thickness = 30

class Outline
constructor: ->
@step   = min(p5.width / 30, 40)
@points = []
@ease  = 0.2
@elas  = 0.95

for x in [@step..p5.width-@step] by @step
@points.push [x, p5.height * 2 / 3, p5.height * 2 / 3, 0]

noiseFor: (x) ->
noise(x * 0.01, p5.frameCount * 0.1) * 30 +
noise(x * 0.1, p5.frameCount * 0.2) * 10

draw: ->
noStroke()
fill 140, 80, 30
strokeWeight random(10, 15)
stroke 200, 150, 60
beginShape()
maxy = 0
for p in @points
if p[1] != p[2]
p[1] += p[3] = (p[3] * @elas + (p[2] - p[1]) * @ease)
x = p[0]
y = p[1] + @noiseFor(p[0])
curveVertex x, y
maxy = max y, maxy

for i in [@points.length-1..0]
p = @points[i]
curveVertex p[0], maxy + @noiseFor(p[0]) +
noise(p[0] * 0.01, p5.frameCount * 0.05) * thickness
curveVertex @points[0][0], @points[0][1] + @noiseFor(@points[0][0])
np1 = @noiseFor(@points[1][0])
for i in [0...2]
curveVertex @points[1][0], @points[1][1] + np1
endShape()

stroke 140, 80, 30

for p in @points
for i in [0...4]
strokeWeight random(1, 5)
point p[0] + random(-@step, @step),
p[1] + random(-@step, @step)
point p[0] + random(-@step, @step),
maxy + thickness + random(-@step, @step)

for i in [0...100]
strokeWeight random(1, 5)
point random(p5.width), random(p5.height)

qcurve = (t, n) ->
for i in [0...n]
t = 6 * pow(t, 5) - 15 * pow(t, 4) + 10 * pow(t, 3)
t

exert = (mx, my) ->
for t in traces
for p in t.points
r = qcurve( pow(abs(mx - p[0]) / p5.width, 0.1), 2 )
console.log [mx, p[0], r]
p[2] = r * p[2] + (1 - r) * my

setup = ->
size         \$(window).width(), \$(window).height()
frameRate    30
background   255
strokeWeight 3
fill         0

traces.push new Outline()

for pct in [30..70]
for i in [0..4]
exert p5.width * pct * 0.01, p5.height *
if pct > 33 and pct < 55
0.16
else if pct >= 55 and pct < 60
0.28
else if pct >= 60 and pct < 70
0.2
else
0.25

draw = ->
background 255
t.draw() for t in traces
exert p5.mouseX, p5.mouseY if p5.__mousePressed```
» capture | close