|
|
|
@ -51,6 +51,7 @@ function draw_initstate(p, state) {
@@ -51,6 +51,7 @@ function draw_initstate(p, state) {
|
|
|
|
|
if(!('dir' in state)) { |
|
|
|
|
state.dir = 0; |
|
|
|
|
state.turnnoise = 0; |
|
|
|
|
state.lennoise = 0; |
|
|
|
|
} |
|
|
|
|
if(!('stepsize' in state)) { |
|
|
|
|
state.stepsize = 1; |
|
|
|
@ -76,6 +77,13 @@ function draw_set_turn_noise(level) {
@@ -76,6 +77,13 @@ function draw_set_turn_noise(level) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function draw_set_length_noise(level) { |
|
|
|
|
return function(p, state) { |
|
|
|
|
state.lennoise = level; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function draw_forward(factor=1) { |
|
|
|
|
return function(p, state) { |
|
|
|
|
draw_initstate(p, state); |
|
|
|
@ -84,10 +92,11 @@ function draw_forward(factor=1) {
@@ -84,10 +92,11 @@ function draw_forward(factor=1) {
|
|
|
|
|
console.log('---------------------------'); |
|
|
|
|
} |
|
|
|
|
var lastp = state.curpath.segments[state.curpath.segments.length - 1].point; |
|
|
|
|
state.curpath.add(lastp.add( |
|
|
|
|
new paper.Point(Math.sin(state.dir) * state.stepsize * factor, |
|
|
|
|
Math.cos(state.dir) * state.stepsize * factor) |
|
|
|
|
)); |
|
|
|
|
var noise = 1 + (Math.random() - 0.5) * state.lennoise; |
|
|
|
|
state.curpath.add(lastp.add(new paper.Point( |
|
|
|
|
Math.sin(state.dir) * state.stepsize * factor * noise, |
|
|
|
|
Math.cos(state.dir) * state.stepsize * factor * noise |
|
|
|
|
))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|