Trippy Triangles

A modification of this

Rotating shapes

Log in to post a comment.

Canvas.setpenopacity(.75);

const min_radius = 0;
const radius_step = 0.5;
const steps = 30;
const rotate_per_step = .025;
const elems_side = 5;

const turtle = new Turtle();
turtle.radians();   

sides = [3,]
    
function walk(i) {
    for (let x=0; x<elems_side; x++) {
        for (let y=0; y<elems_side; y++) {
            ind = Math.round(Math.random()*1)
            corners = sides[ind]
            console.log(corners)
            draw_poly( (x/elems_side-.5*(1-1/elems_side))*200,
                       (y/elems_side-.5*(1-1/elems_side))*200, turtle, 
                    corners,
                    i*radius_step+min_radius, // radius
                    (steps-i-1) * rotate_per_step * (1+y), // angle
                );    
        }
    }
    return i < steps-1;
}


function draw_poly(x,y,t, c, r, a) {
    const side = 2*Math.sin(Math.PI/c) * r;
    
    t.penup();
    t.goto(x,y);
    t.setheading(a);
    t.forward(r);
    t.setheading(a+Math.PI/2);
    t.pendown();
    
    t.right(Math.PI/c);
    for (let i=0; i<c; i++) {
        t.forward(side);
        t.right(Math.PI*2/c);
    }
}