// Based on Listing 5.1, Generative Art float xstart, xnoise, ystart, ynoise, tnoise; float x_end1, y_end1; float x_end2, y_end2; int num = 1; Walker[] walkers = new Walker[num]; float magnitude; float angle; float noise_speed; int width = 500; int height= 500; int cache_len = width * height; float[] temp_xy; float[][] mag_angle_list = new float[250000][2]; int j,k; void setup() { size(500, 500); background(255); xstart = random(10); ystart = random(10); frameRate(25); textSize(30); for (int i = 0; i < num; i++){ walkers[i] = new Walker(i); } } void draw() { background(255); // println(frameRate); // xstart += 0.01; // ystart += 0.01; ynoise = ystart; j = 0; for (int y = 1; y <= height; y+=1) { ynoise += 0.01; xnoise = xstart; for (int x = 1; x <= width; x+=1) { xnoise += 0.01; angle = noise(xnoise, ynoise, tnoise) * 3.14 * 2; x_end1 = (1 * cos(angle)) + x; y_end1 = (1 * sin(angle)) + y; mag_angle_list[j][0] = x_end1; mag_angle_list[j][1] = y_end1; j = j + 1; } } for (int i = 0; i < num; i++){ temp_xy = walkers[i].getLocation(); // lookup mechanism int idx = (int)(((temp_xy[1] - 1) * width) + temp_xy[0]); float next_x = mag_angle_list[idx][0]; float next_y = mag_angle_list[idx][1]; walkers[i].update(next_x,next_y); print(next_x); } } class Walker { // fields String s; float x, y, a; float tx, ty, ta; color c; // constructor Walker(int i) { s = nf(i); x = random(width); y = random(height); tx = random(1000); ty = random(1000); ta = random(1000); c = color(2,2,2); // c = color(random(255),random(255),random(255)); } float[] getLocation(){ return new float[]{x,y}; } // method void update(float next_x, float next_y) { pushMatrix(); translate(x, y); rotate(a); fill(c, 100); text(s, 0, 0); popMatrix(); tx += 0.01; ty += 0.01; ta += 0.001; x += next_x; y += next_y; a += 0.1-0.05; if (x<0) x += width; else if (x>width) x -= width; if (y<0) y += height; else if (y>height) y -= height; } }