I was messing around the function to draw an ellipse and got it to draw this which I thought was cool.
I have a backlog of projects like this one that I have thought about releasing but I don't want to flood the feed, should I release them?
Log in to post a comment.
// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
// Global code will be evaluated once.
const turtle = new Turtle();
const ellipse_steps = 25; // min = 1 max = 30 step = 1
const steps = 15; // min = 1 max = 15 step = 1
const step_size = 1.3;
const a = 25;
const b = 0;
const draw_grid = 1; // min=0 max=1 step=1 (No, Yes)
function wrong_ellipse(steps, a, b, theta, x_center, y_center) {
t = Math.PI * 2 / steps;
turtle.penup();
for(i = 0; i <= steps; i++) {
if(i == 1) {
turtle.pendown();
}
x = x_center + a*Math.cos(theta)*Math.sin(t*i) - b*Math.sin(theta)*Math.sin(t*i);
y = y_center + a*Math.sin(theta)*Math.cos(t*i) + b*Math.cos(theta)*Math.sin(t*i);
turtle.goto(x,y);
}
}
function walk(i, t) {
if(draw_grid) {
for(let i = -100; i < 150; i+=a) {
for(let j = -100; j < 150; j+=a) {
if((i+j)%(2*a)==0) {
for(let k = 0; k < step_size*steps; k+=step_size) {
wrong_ellipse(ellipse_steps, a, b, k, i, j)
}
}
}
}
}
else {
for(let k = 0; k < t; k++) {
wrong_ellipse(ellipse_steps, 100, b, t*step_size, 0, 0)
}
}
return false;
}