Type in a sentence/word (more than 2 letters) in all caps under the variable "sent" and it will be translated into the code.
xxxxxxxxxx
var sent = "PICTURED AS PERFECT";
function ltn(l) {
var alph = [" ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
for (i = 0; i < 27; i++) {
if (alph[i] === l) {
return i;
}
}
}
function ptn(p) {
var ns = [];
for (j = 0; j < p.length; j++) {
ns.push(ltn(p[j]));
}
return ns;
}
function b10tb3(x) { // x < 27
return str(floor(floor(x/3)/3)%3) + str(floor(x/3)%3) + str(x%3);
}
function b3p(s) {
var b3s = [];
for (k = 0; k < s.length; k++) {
b3s.push(b10tb3(int(ptn(s)[k])));
}
return b3s;
}
function rend(s) { // s.length < 3
for (z = 0; z < s.length; z++) {
for (y = 0; y < 3; y++) {
if (b3p(s)[z][y] === "0") {
fill(0);
stroke(0);
} else if (b3p(s)[z][y] === "1") {
fill(255);
stroke(255);
} else if (b3p(s)[z][y] === "2") {
fill(255, 0, 255);
stroke(255, 0, 255);
}
noStroke();
rect(width-(z*width/s.length), (2-y)*height/s.length, -width/s.length, height/s.length);
}
}
}
function setup() {
createCanvas(800, 800);
background(10, 10, 10);
noLoop();
}
function draw() {
rend(sent);
}