check here Attraction
Log in to post a comment.
Canvas.setpenopacity(-1); const turtle = new Turtle(); const step = 0.001; const scale = 1; const pointsCount = 45; let points = []; const time = -0.5; let t = time; function nextX(x, y, t) { return x+y*t; } function nextY(x, y, t) { return y-x*t; } function getPoints(t) { const newPoints = []; let x = t; let y = t; newPoints.push([x, y]); for (let i = 0; i < pointsCount - 1; i++) { let newX = nextX(x, y, t); let newY = nextY(x, y, t); x = newX; y = newY; newPoints.push([x, y]); } return newPoints; } // init points = getPoints(t); function walk(i) { t += step; let newPoints = getPoints(t); for (let i = 0; i < points.length; i++) { turtle.penup(); turtle.goto(points[i][0] * scale, points[i][1] * scale); turtle.pendown(); turtle.goto(newPoints[i][0] * scale, newPoints[i][1] * scale); } points = newPoints; return t < 0; }