Language

turtle lettering

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();


function drawLetter(let, x, y, size) {
    var points = Letter[let];
    if (typeof points == 'undefined' || points.length < 1) return;
    turtle.penup();
    for (var i = 0; i < points.length - 1; i = i+2) {
        turtle.goto(x+points[i]*size,y-points[i+1]*size);
        if (i == 0) turtle.pendown();
    }
}

function drawWord(word, x, y, size) {
    word = word.toUpperCase();
    for (var i = 0; i < word.length; i++) {
        // repeat the letter shifted to darken/shadow
        [0,0.1,0.2,0.3,0.4].forEach(function(shift) {
            drawLetter(word[i], x+shift, y+shift, size);
        });
        // letter spacing
        if (word[i] == 'I') { x += size-3 } else x += size+1;
    }
}

function walk(i) {
    drawWord("Language is a virus", -85, -30, 8);
    drawWord("from outer space", -75, -15, 8);
    drawWord("William S Burroughs", -85, 10, 8);
    return i < 0;
}



var Letter = new Array();
Letter['A'] = new Array(0,0,0.5,1,0.75,0.5,0.25,0.5,0.75,0.5,1,0);
Letter['B'] = new Array(0,0,0,1,0.625,1,0.75,0.875,0.75,0.625,0.625,0.5,0,0.5,0.625,0.5,0.75,0.375,0.75,0.125,0.625,0,0,0);
Letter['C'] = new Array(0.75,0.125,0.625,0,0.125,0,0,0.125,0,0.875,0.125,1,0.625,1,0.75,0.875);
Letter['D'] = new Array(0,0,0,1,0.625,1,0.75,0.875,0.75,0.125,0.625,0,0,0);
Letter['E'] = new Array(0.75,0,0,0,0,0.5,0.75,0.5,0,0.5,0,1,0.75,1);
Letter['F'] = new Array(0,0,0,0.5,0.75,0.5,0,0.5,0,1,0.75,1);
Letter['G'] = new Array(0.75,0.5,0.625,0.5,0.75,0.5,0.75,0.125,0.625,0,0.125,0,0,0.125,0,0.875,0.125,1,0.625,1,0.75,0.875);
Letter['H'] = new Array(0,0,0,1,0,0.5,0.75,0.5,0.75,1,0.75,0);
Letter['I'] = new Array(0,0,0.25,0,0.125,0,0.125,1,0,1,0.25,1);
Letter['J'] = new Array(0,0.125,0.125,0,0.375,0,0.5,0.125,0.5,1);
Letter['K'] = new Array(0,0,0,1,0,0.5,0.75,1,0,0.5,0.75,0);
Letter['L'] = new Array(0,0,0,1,0,0,0.75,0);
Letter['M'] = new Array(0,0,0,1,0.5,0,1,1,1,0);
Letter['N'] = new Array(0,0,0,1,0.75,0,0.75,1);
Letter['O'] = new Array(0.75,0.125,0.625,0,0.125,0,0,0.125,0,0.875,0.125,1,0.625,1,0.75,0.875,0.75,0.125);
Letter['P'] = new Array(0,0,0,1,0.625,1,0.75,0.875,0.75,0.625,0.625,0.5,0,0.5);
Letter['Q'] = new Array(0.75,0.125,0.625,0,0.125,0,0,0.125,0,0.875,0.125,1,0.625,1,0.75,0.875,0.75,0.125,0.875,0);
Letter['R'] = new Array(0,0,0,1,0.625,1,0.75,0.875,0.75,0.625,0.625,0.5,0,0.5,0.625,0.5,0.875,0);
Letter['S'] = new Array(0,0.125,0.125,0,0.625,0,0.75,0.125,0.75,0.375,0.675,0.5,0.125,0.5,0,0.625,0,0.875,0.125,1,0.625,1,0.75,0.875);
Letter['T'] = new Array(0,1,0.5,1,0.5,0,0.5,1,1,1);
Letter['U'] = new Array(0,1,0,0.125,0.125,0,0.625,0,0.75,0.125,0.75,1);
Letter['V'] = new Array(0,1,0.375,0,0.75,1);
Letter['W'] = new Array(0,1,0.25,0,0.5,1,0.75,0,1,1);
Letter['X'] = new Array(0,0,0.375,0.5,0,1,0.375,0.5,0.75,1,0.375,0.5,0.75,0);
Letter['Y'] = new Array(0,1,0.375,0.5,0.375,0,0.375,0.5,0.75,1);
Letter['Z'] = new Array(0,1,0.75,1,0,0,0.75,0);
Letter[' '] = new Array();