// Array 2D // by REAS <http://reas.com> // Demonstrates the syntax for creating a two-dimensional (2D) array. // Values in a 2D array are accessed through two index values. // 2D arrays are useful for storing images. In this example, each dot // is Stringed in relation to its distance from the center of the image. // Created 09 December 2002 // Modified for Processing.NET double[,] distances; // MODIFIED double maxDistance; size(200, 200); background(0); maxDistance = dist(width/2, height/2, width, height); distances = new double[width,height]; // MODIFIED for(int i=0; i<height; i++) { for(int j=0; j<width; j++) { double dist2 = dist(width/2, height/2, j, i); // MODIFIED distances[j,i] = dist2/maxDistance * 255; // MODIFIED } } for(int i=0; i<height; i+=2) { for(int j=0; j<width; j+=2) { stroke(distances[j,i]); // MODIFIED point(j, i); } }