xxxxxxxxxx
84
let letters = [];
function setup() {
createCanvas(900, 900);
for(x = 0; x < width / 15; x++){
for(y = 0; y < height / 25; y++){
letters[letters.length] = new Letter(x * 15, y * 25);
}
}
}
function draw() {
background(220);
for(i = 0; i < letters.length; i++){
letters[i].update();
}
noLoop();
}
class Letter{
constructor(x, y){
this.x = x;
this.y = y;
this.width = 10;
this.height = 20;
this.s1 = floor(random(2));
this.s2 = floor(random(2));
this.s3 = floor(random(2));
this.s4 = floor(random(2));
this.s5 = floor(random(2));
this.s6 = floor(random(2));
this.s7 = floor(random(2));
this.s8 = floor(random(2));
this.s9 = floor(random(2));
}
update(){
//left side
if(this.s1 == 1){
strokeWeight(random(3));
line(this.x, this.y, this.x, this.y + this.height);
}
//top
if(this.s2 == 1){
strokeWeight(random(3));
line(this.x, this.y, this.x + this.width, this.y);
}
//right side
if(this.s3 == 1){
strokeWeight(random(3));
line(this.x + this.width, this.y, this.x + this.width, this.y + this.height);
}
//bottom
if(this.s4 == 1){
strokeWeight(random(3));
line(this.x, this.y + this.height, this.x + this.width, this.y + this.height);
}
//mid cross
if(this.s5 == 1){
strokeWeight(random(3));
line(this.x, this.y + this.height / 2, this.x + this.width, this.y + this.height / 2);
}
//mid to top
if(this.s6 == 1){
strokeWeight(random(3));
line(this.x + this.width / 2, this.y, this.x + this.width / 2, this.y + this.height / 2);
}
//mid to bottom
if(this.s7 == 1){
strokeWeight(random(3));
line(this.x + this.width / 2, this.y + this.height / 2, this.x + this.width / 2, this.y + this.height);
}
//mid to tr
if(this.s8 == 1){
strokeWeight(random(3));
line(this.x + this.width / 2, this.y + this.height / 2, this.x + this.width, this.y);
}
//mid to br
if(this.s9 == 1){
strokeWeight(random(3));
line(this.x + this.width / 2, this.y + this.height / 2, this.x + this.width, this.y + this.height);
}
}
}