See page 38
direct.mit.edu/books…uter-as-a-medium-for
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
// inspired by https://direct.mit.edu/books/oa-monograph/4663/Turtle-GeometryThe-Computer-as-a-Medium-for
// Turtle Geometry: The Computer as a Medium for Exploring Mathematics
// Harold Abelson, Andrea diSessa
// The MIT Press
// DOI: https://doi.org/10.7551/mitpress/6933.001.0001
// ISBN electronic: 9780262362740
// Publication date: 1981
// Global code will be evaluated once.
const turtle = new Turtle();
const n = 9; //min=9 max=39 step=1
const scale = 7; // min=1 max=8 step=1
const angle = 90;
const index = 0;
var count = 0;
turtle.penup();
turtle.goto(-30,-30);
turtle.pendown();
// The walk function will be called until it returns false.
function walk(i) {
subgspiro(scale,angle,n, 3, 4, 5);
i++;
return i < n;
}
function subgspiro (side, angle, max, a, b, c ){
count = 1;
turtle.pendown();
for (var i = 0; i < max; i++) {
step = side * count;
turtle.forward(step);
if((count == a) || (count == b) || count==c){
turtle.left(angle);
}
else{
turtle.right(angle);
}
count ++;
}
}