topical media & game development
graphic-processing-learning-13-example-13-9-example-13-9.pde / pde
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Example 13-9: Two-dimensional array
// Set up dimensions
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));
}
}
// Draw points
for (int i = 0; i < cols; i ++ ) {
for (int j = 0; j < rows; j ++ ) {
stroke(myArray[i][j]);
point(i,j);
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.