|
|
@ -136,7 +136,7 @@ function sierpinski() { |
|
|
|
function barnsley_fern() { |
|
|
|
function barnsley_fern() { |
|
|
|
project.clear(); |
|
|
|
project.clear(); |
|
|
|
var r = generate( |
|
|
|
var r = generate( |
|
|
|
'IXF'.split(''), |
|
|
|
'iIXF'.split(''), |
|
|
|
[ |
|
|
|
[ |
|
|
|
['X'.split(''), 'F+[[X]-X]-F[-FX]+X'.split('')], |
|
|
|
['X'.split(''), 'F+[[X]-X]-F[-FX]+X'.split('')], |
|
|
|
['F'.split(''), 'FF'.split('')] |
|
|
|
['F'.split(''), 'FF'.split('')] |
|
|
@ -149,7 +149,8 @@ function sierpinski() { |
|
|
|
r, |
|
|
|
r, |
|
|
|
{ |
|
|
|
{ |
|
|
|
'F': draw_forward(), |
|
|
|
'F': draw_forward(), |
|
|
|
'I': draw_angle_init(25/180 * Math.PI), |
|
|
|
'i': draw_set_dir(Math.PI), |
|
|
|
|
|
|
|
'I': draw_angle_init(25/180 * Math.PI + Math.random() * 0.2), |
|
|
|
'-': draw_angle_turn(-1), |
|
|
|
'-': draw_angle_turn(-1), |
|
|
|
'+': draw_angle_turn(1), |
|
|
|
'+': draw_angle_turn(1), |
|
|
|
'[': draw_state_push(), |
|
|
|
'[': draw_state_push(), |
|
|
@ -157,7 +158,7 @@ function sierpinski() { |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
p.scale(2); |
|
|
|
p.scale(2); |
|
|
|
p.translate(new Point(200, 200)); |
|
|
|
p.translate(new Point(200, 300)); |
|
|
|
p.strokeWidth = 1; |
|
|
|
p.strokeWidth = 1; |
|
|
|
p.strokeColor = '#ff00ff'; |
|
|
|
p.strokeColor = '#ff00ff'; |
|
|
|
} |
|
|
|
} |
|
|
|