// Cardioid. Created by Reinder Nijhoff 2019
// @reindernijhoff
//
// https://turtletoy.net/turtle/2f124ae363
//
// Based on: https://martinmcbride.org/post/generative-art/cardioid-string-art/
//

Canvas.setpenopacity(-.2);

const points = 1000;
const radius = 80;
const turtle = new Turtle();
const norm = Math.PI * 2 / points;

function walk(i) {
    const sp = i, ep = (i * 2) % points;
    
    turtle.jump(radius*Math.cos(sp * norm), radius*Math.sin(sp * norm));
    turtle.goto(radius*Math.cos(ep * norm), radius*Math.sin(ep * norm));
    
    return i < points;
}