Log in to post a comment.

Canvas.setpenopacity(0.12);
const turtle = new Turtle();
turtle.penup();


const a = -0.406;
const b = 1;
const scale = 3.5;
const initialPosition = {x: 5, y: 5};
const iterations = 200000;

let position = initialPosition;
const positions = getPositions(iterations);

function walk(i) {
    drawPoint(positions[i].x * scale,positions[i].y * scale);       
    return i < positions.length -1;
}


function drawPoint(x, y) {
    turtle.goto(x,y);
    turtle.pendown();
    turtle.forward(1)
    turtle.penup();
}

function gumowskiMira(value) {
    const squared = value * value;
    return a * value + (2 * (1 - a) * squared) / (1 + squared);
}

function getPositions(amount) {
    const results = [];

    for (let i = 0; i < amount; i += 1) {
      const newX = b * position.y + gumowskiMira(position.x);
      const newY = -position.x + gumowskiMira(newX);
      const newPosition = { x: newX, y: newY };

      results.push(newPosition);

      position = newPosition;
    }

    return results;
  }