Circles 🌘
Simple turtle, inspired by twitter.com/paulrick…/1117819286695944192
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
const draw_size = 50;
const grid = 5; // min=1, max=90, step=1
const radius = 15; // min=1, max=90, step=1
const distance = 40; // min=1, max=50, step=1
const minLines = 3; // min=0, max=10, step=0.01
const turtle = new Turtle();
function walk(i) {
const x = i % grid;
const y = i / grid | 0
const startPos = [x * distance, y * distance];
const startAngle = Math.random() * Math.PI*2;
for (let z = 0; z < ((x + minLines) * (y + minLines)); z+=3) {
const a1 = startAngle + getAngle1();
const a2 = startAngle + getAngle2();
line(
startPos[0] + Math.cos(a1) * radius,
startPos[1] + Math.sin(a1) * radius,
startPos[0] + Math.cos(a2) * radius,
startPos[1] + Math.sin(a2) * radius
);
}
return i < grid * grid - 1;
}
const totalAngles = 100; //min=0, max=100, step=1
const getAngle1 = () => Math.round(Math.random()*totalAngles)/totalAngles * Math.PI;
const getAngle2 = () => Math.PI + Math.round(Math.random()*totalAngles)/totalAngles * Math.PI;
const line = (x1, y1, x2, y2) => {
const s = (grid - 1) * distance / 2;
x1 -= s;
x2 -= s;
y1 -= s;
y2 -= s;
turtle.jump(x1, y1);
turtle.goto(x2, y2);
}