Firework

Added sliders to make this easier to experiment with as you get some cool effects by inverting the radii values.

Log in to post a comment.

// Forked from "Expanding Circles" by dinubs
// https://turtletoy.net/turtle/5ff4c64505

// 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();
let radiusMin = 1; // min=0, max=20, step=1
let radiusMax = 10;  // min=1, max=30, step=1
let lineLengthMin = 5; // min=0, max=20, step=1
let lineLengthMax = 10;  // min=1, max=30, step=1
let iterations = 8; // min=1, max=30, step=1
let fraction = 1; // min=1, max=30, step=1

function random(range) {
  return Math.floor(Math.random() * (range[1] - range[0]) ) + range[0];
}

// The walk function will be called until it returns false.
function walk(i) {
    turtle.home();
    turtle.seth(i / fraction);
    turtle.penup();
    const multiplier = Math.floor(i / 360) + .5;
    turtle.forward(random([radiusMin,radiusMax]) * multiplier);
    turtle.pendown()
    turtle.forward(random([lineLengthMin,lineLengthMax]));
    
    return i < 360 * iterations;
}