10 PRINT Pattern

The '10 PRINT CHR$(205.5+RND(1)); : GOTO 10' pattern refers to a famous one-line program for the Commodore 64 that creates a maze-like pattern on the screen using diagonal slash characters. This program randomly chooses between two characters: a forward slash '/' and a backslash '\'.

Log in to post a comment.

// 10 PRINT Pattern in TurtleToy
Canvas.setpenopacity(1);
const turtle = new Turtle();

const gridSize = 4; // min=0 max=100 step=1 // Size of each grid cell
const gridWidth = 30; // min=0 max=100 step=1 // Width of the grid (number of cells)
const gridHeight = 30; // min=0 max=100 step=1 // Height of the grid (number of cells)
const moveY = -50;// min=-50 max=0 step=1 
const moveX = -50;// min=-50 max=0 step=1 

turtle.penup();

for (let y = moveY; y < gridHeight; y++) {
    for (let x = moveX; x < gridWidth; x++) {
        drawSlash(x * gridSize, y * gridSize, gridSize);
    }
}

function drawSlash(x, y, size) {
    // Randomly choose to draw / or \
    if (Math.random() > 0.5) {
        // Draw /
        turtle.goto(x, y);
        turtle.pendown();
        turtle.goto(x + size, y + size);
        turtle.penup();
    } else {
        // Draw \
        turtle.goto(x + size, y);
        turtle.pendown();
        turtle.goto(x, y + size);
        turtle.penup();
    }
}

function loop() {
    return false;
}