Try fiddling with the parameters :)
Log in to post a comment.
// adpated from https://www.101computing.net/python-turtle-spirograph/ Canvas.setpenopacity(.5) const theta = 0.2 function Spirograph(R, r, d, rotations, scale = 1, offsetX = 0, offsetY = 0) { this.turtle = new Turtle() this.turtle.penup() this.turtle.goto((R-r+d) * scale, 0) this.turtle.pendown() this.angle = 0 this.walk = function(i) { x = (R - r) * Math.cos(this.angle) + d * Math.cos(((R-r)/r)*this.angle) y = (R - r) * Math.sin(this.angle) - d * Math.sin(((R-r)/r)*this.angle) x = x * scale + offsetX y = y * scale + offsetY this.turtle.goto(x,y) this.angle += theta return i < rotations * Math.PI / theta } } spiros = [] spiros.push(new Spirograph(125 / 2, 25 / 2, 205 / 2, 64, 0.6)) spiros.push(new Spirograph(75, 85, 125, 34, 0.125)) spiros.push(new Spirograph(120, 65, 120, 26, 0.06)) function walk(i) { spiros = spiros.filter(spiro => spiro.walk(i)) return spiros.length > 0 }