xxxxxxxxxx
48
/*
----- Coding Tutorial by Patt Vira -----
Name: Interactive Secret Message
Video Tutorial: https://youtu.be/zau6noH8jag?si=8czjEyoPO9BU1Q9o
Connect with Patt: @pattvira
https://www.pattvira.com/
----------------------------------------
*/
let cols; let rows; let csize = 4; let rsize = 5;
let img;
let rects = [];
function preload() {
img = loadImage("images/BIGGER.png");
}
function setup() {
createCanvas(800, 200);
cols = width/csize;
rows = height/rsize;
let bright;
for (let i=0; i<cols; i++) {
rects[i] = [];
for (let j=0; j<rows; j++) {
let c = img.get(i*csize, j*rsize);
if (brightness(c) == 0) {
bright = true;
} else {
bright = false;
}
rects[i][j] = new Rect(i*csize, j*rsize, bright);
}
}
}
function draw() {
background(220);
// image(img, 0, 0);
for (let i=0; i<cols; i++) {
for (let j=0; j<rows; j++) {
rects[i][j].display();
}
}
}