Totally Zen

Totally Zenned out #yinyang

Log in to post a comment.

// Global code will be evaluated once.
Canvas.setpenopacity(.025)

const turtle = new Turtle()

polySize = 5.0
size = 0.5

// The walk function will be called until it returns false.
function walk(i) {
    progress = i % stepsPerYinYang
    offset = Math.floor(i / stepsPerYinYang)

    if (progress === 0) {
        turtle.penup()
        turtle.goto(0, 0)
        turtle.right(offset / 720)
        turtle.pendown()
    }
    
    walkYinYang(progress)

    return i < stepsPerYinYang * 720
}

stepsPerYinYang = (360 + 90 + 90) / polySize

function walkYinYang(i) {
    turtle.forward(polySize * size)
    if (i < 360 / polySize) {
        turtle.right(polySize)
    } else if (i < (360 + 90) / polySize) {
        turtle.right(2 * polySize)
    } else if (i < (360 + 90 + 90) / polySize) {
        turtle.right(-2 * polySize)
    }
}