/** * Geometry * by Marius Watz. * * Using sin/cos lookup tables, blends colors, and draws a series of * rotating arcs on the screen. * *Edited by Gary Judge */ import processing.opengl.*; // Trig lookup tables borrowed from Toxi. Cryptic but effective float sinLUT[]; float cosLUT[]; float SINCOS_PRECISION=1.5; int SINCOS_LENGTH= int((360.0/SINCOS_PRECISION)); // System data boolean dosave=false; int num; float pt[]; int style[]; void setup() { size(1024, 768, OPENGL); frameRate(24); background(153); // Fill the tables sinLUT=new float[SINCOS_LENGTH]; cosLUT=new float[SINCOS_LENGTH]; for (int i = 0; i < SINCOS_LENGTH; i++) { sinLUT[i]= (float)Math.sin(i*DEG_TO_RAD*SINCOS_PRECISION); cosLUT[i]= (float)Math.cos(i*DEG_TO_RAD*SINCOS_PRECISION); } num = 100; pt = new float[10*num]; // rotx, roty, deg, rad, w, speed style = new int[10*num]; // color, render style // Set up arc shapes int index=0; float prob; for (int i=0; i90) pt[index]=(int)random(8,27)*10; pt[index++] = int(random(2,150)*6); // Radius. Space them out nicely pt[index++] = random(4,32); // Width of band if(random(100)>90) pt[index]=random(800,200); // Width of band pt[index++] = radians(random(5,20))/2; // Speed of rotation // get colors prob = random(100); if(prob<30) style[i*2]=colorBlended(random(1), 0,0,100, 100,0,0, 210); else if(prob<70) style[i*2]=colorBlended(random(1), 0,153,0, 170,225,255, 210); else if(prob<90) style[i*2]=colorBlended(random(1), 153,255,0, 150,255,0, 210); else style[i*2]=color(255,0,255, 220); if(prob<50) style[i*2]=colorBlended(random(1), 200,255,0, 50,120,0, 210); else if(prob<90) style[i*2]=colorBlended(random(1), 255,100,0, 255,255,0, 210); else style[i*2]=color(255,255,255, 220); style[i*2+1]=(int)(random(100))%3; } } void draw() { background(0); int index=0; translate(width/2, height/2, 0); rotateX(PI/8); rotateY(PI/9); for (int i=0; i