int xspacing = 10; int w; float theta =0.0; float amplitude = 5.0; float period = 20.0; float dx; float[] yvalues; void setup() { size(200,200); w = width+16; dx = (TWO_PI / period) * xspacing; yvalues = new float[w/xspacing]; } void draw() { background(255); //tree fill(12,134,29); noStroke(); triangle(100,30,60,70,140,70); triangle(100,20,70,50,130,50); triangle(100,40,50,90,150,90); triangle(100,50,40,110,160,110); triangle(100,60,30,130,170,130); triangle(100,70,20,150,180,150); fill(132,92,56); noStroke(); rect(80,150,40,30); //light calcWave(); renderWave(); } void calcWave() { theta +=0.02; float x = theta; for (int i = 0; i < yvalues.length; i++) { yvalues[i] = sin(x)*amplitude; x+=dx; } } void renderWave() { for (int x = 0; x < yvalues.length; x++) { noStroke(); fill(255,248,101); ellipse(x*xspacing,width/2+yvalues[x],10,10); } }