Hi! I’m brand new to coding with P5JS and I need some help. I’m currently taking a class for it and I’ve been watching a bunch of The Coding Train videos. For my specific project I’m trying to implement 30 unique colors into a grid array. From class/watching videos I have learned how to apply random colors to a group of grid squares, but not how to apply a specific color to an individual one. I don’t need help with all of the squares, but if someone can help with a few squares I should hopefully be able to do the rest.
For an example, let’s say I want the color (255, 0, 0) in grid square (2,4), the color (0, 255, 0) in grid square (5,1), and the color (0, 0, 255) in grid square (3,6).
I have the grid set up-
Here’s the section of my code:
var cols = 5;
var rows = 6;
function setup(){
createCanvas(750,1125,WEBGL);
}
function draw(){
background (0);
translate(-width/2,-height/2);
for (var i= 0; i < cols; i++) {
for (var j = 0; j < rows; j++) {
var x = i * 150;
var y = j * 187.5;
stroke(0)
fill(255);
rect(x, y, 150, 187.5);
}
}