Stripe[] stripes = new Stripe[20]; float colVar_r; float colVar_g; float colVar_b; void setup(){ size(400, 300); //initialise stripes for(int i = 0; i< stripes.length; i++){ stripes[i] = new Stripe(); } } void draw(){ background(150); //move and display stripes for(int i = 0; i< stripes.length; i++){ //is mouse over stripe? stripes[i].rollover(mouseX,mouseY); stripes[i].move(); stripes[i].display(); } } class Stripe{ float x; float speed; float w; boolean mouse; Stripe(){ x = 0; speed = random(1); w = random(10,40); mouse = false; } //draw stripe void display(){ if(mouse){ colVar_r = random(255); colVar_g = random(255); colVar_b = random(255); fill(colVar_r,colVar_g,colVar_b); //fill(255); }else{ fill(255,60); } noStroke(); rect(x,0,w,height); } //move stripe void move(){ x += speed; if(x > width+20)x = - 20; } //check if point is inside stripe void rollover(int mx, int my){ //left edge = x, right edge = x+w if(mx > x && mx < x + w){ mouse = true; }else{ mouse = false; } } }