spacexplorer
YaBB Newbies
Offline
Posts: 2
Making the rectangles grow in size upon rollover
Jan 13th , 2008, 5:56pm
Hi, you can probably tell by the name of this subject how new I am to Processing... I am learning about it in school, and I've been working on this code for a project... I was just wondering how I could manage to make the individual rectangles grow in size upon rollover while they move in a wave like motion... I used the Additive Wave example as a basis, and I'm making changes from there. Here is the code so far: int xspacing = 10; int w; int maxwaves = 15; float theta = 0.0f; float[] amplitude = new float[maxwaves]; float[] dx = new float[maxwaves]; float[] yvalues; void setup() { size(800,600); frameRate(60); colorMode(RGB, 255, 255, 255, 100); smooth(); w = width+16; for (int i = 0; i < maxwaves; i++) { amplitude[i] = random(10,30); float period = random(100,200); dx[i] = (TWO_PI / period) * xspacing; } yvalues = new float[w/xspacing]; } void draw() { background(255); calcWave(); renderWave(); } void calcWave() { theta += 0.03; for (int i = 0; i < yvalues.length; i++) { yvalues[i] = 0.0f; } for (int j = 0; j < maxwaves; j++) { float x = theta; for (int i = 0; i < yvalues.length; i++) { if (j % 2 == 0) yvalues[i] += sin(x)*amplitude[j]; else yvalues[i] += cos(x)*amplitude[j]; x+=dx[j]; } } } void renderWave() { noStroke(); fill(120, 30); rectMode(CENTER); for (int x = 0; x < yvalues.length; x++) { rect(x*xspacing,width/2+yvalues[x],30,30); } } If any of you experts could give me some idea of how to integrate the mouseX or mouseY function into this to make the shapes grow, I'd be utterly grateful!!!