Fisheye Squares

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 = 25 step = 1
const steps = 15; 
const step_size = 1.3; 
const a = 25; 
const b = 0; 

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)
            }
        }
    }
}

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);
    }
}