Spiky wave

hello, spiky world

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);

// Global code will be evaluated once.
const turtle = new Turtle();

const cols = 60 // min=20, max=100, step=5
const rows = 60 // min=20, max=100, step=5
const length = 10 // min=0.5, max=20, step=0.5
const gap = 2 // min=0.25, max=20, step=0.5
const twist = 2 // min=0.25, max=5, step=0.25
const twistOrigin = 0.5 // min=-1, max=2, step=0.1

const xOffset = ((gap * cols * -1) / 2) + gap / 2
const yOffset = ((gap * rows * -1) / 2) + gap / 2

// The walk function will be called until it returns false.
function walk(i) {
    const row = Math.floor(i / rows)
    const col = i % rows
    const x = xOffset + (row * gap)
    const y = yOffset + (col * gap)

    turtle.jump(x, y);
    
    turtle.setheading(row + (col * twist));
    turtle.penup()
    turtle.back(length * twistOrigin)
    turtle.pendown()
    turtle.forward(length);
    
    return i + 1 < rows * cols;
}