How to Change the 2d array tutorial example from greyscale to color?
in
Programming Questions
•
2 years ago
Hi all. Here is the script of the tutorial of the 2D Array. It general random greyscale colors, however, I am wondering how to change it into color mode but not greyscale?
// Example: 2D Array size(200,200); int cols = width; int rows = height;
// Declare 2D array int[][] myArray = new int[cols][rows];
// Initialize 2D array values
for (int i = 0; i < cols; i++)
{ for (int j = 0; j < rows; j++)
{ myArray[i][j] = int(random(255)); // This is the part!
} }
// Draw points for (int i = 0; i < cols; i++)
{ for (int j = 0; j < rows; j++)
{ stroke(myArray[i][j]); point(i,j); }
}
Please help. Thank you ever so much.
Yang
1