ArrayList bits;// = new ArrayList(); void keyPressed(){ reset(); } void reset(){ bits = new ArrayList(); for(int i = 0; i < 20; i++){ bits.add(new Bit()); } } void setup(){ size(500,500); noStroke(); reset(); rectMode(CENTER); } float baseangle,baseangle2,basedist; void draw(){ background(255); pushMatrix(); translate(250,250); baseangle = map(mouseX,0,500,-PI,PI); baseangle2 = map(mouseY,0,500,-PI*2,PI*2); basedist = map(mouseY,0,500,0,2); for(Bit b : bits){ b.draw(mouseX-250,mouseY-250); } // stroke(0); // line(0,0,100*cos(baseangle),100*sin(baseangle)); popMatrix(); } class Bit{ float myangle = random(PI*2); float spin; float d = random(50,250); float anglemul = 1;//random(1,2); float as = random(40); float bs = random(40); color c = color(random(128,255),random(128,255),random(128,255)); void draw(float gx, float gy){ spin = baseangle2 * anglemul; float a = baseangle + myangle; drawbit(true,d,cos(a),sin(a)); drawbit(false,d,cos(-a),sin(-a)); drawbit(true,d,cos(PI+a),sin(PI+a)); drawbit(false,d,cos(PI-a),sin(PI-a)); drawbit(true,d,cos(PI/2+a),sin(PI/2+a)); drawbit(false,d,cos(PI/2-a),sin(PI/2-a)); drawbit(true,d,cos(PI*3/2+a),sin(PI*3/2+a)); drawbit(false,d,cos(PI*3/2-a),sin(PI*3/2-a)); drawbit(true,d,cos(PI/4+a),sin(PI/4+a)); drawbit(false,d,cos(PI/4-a),sin(PI/4-a)); drawbit(true,d,cos(PI*3/4+a),sin(PI*3/4+a)); drawbit(false,d,cos(PI*3/4-a),sin(PI*3/4-a)); drawbit(true,d,cos(-PI/4+a),sin(-PI/4+a)); drawbit(false,d,cos(-PI/4-a),sin(-PI/4-a)); drawbit(true,d,cos(-PI*3/4+a),sin(-PI*3/4+a)); drawbit(false,d,cos(-PI*3/4-a),sin(-PI*3/4-a)); } void drawbit(boolean flip, float td,float tx, float ty){ float a = flip ? spin : -spin ; pushMatrix(); translate(td*tx*basedist,td*ty*basedist); rotate(a); fill(c); rect(0,0,as,bs); popMatrix(); } }