//http://processing.org/learning/topics/buttons.html void update(int x, int y) { if(locked == false) { rect1.update(); rect2.update(); } else { locked = false; } if(mousePressed) { if(rect2.pressed()) { currentcolor = rect2.basecolor; if(bgcolor==0){bgcolor=255;}else{bgcolor=0;} if(txcolor==0){txcolor=255;}else{txcolor=0;} setup(); } if(rect1.pressed()) { currentcolor = rect1.basecolor; fill(bgcolor); stroke(bgcolor); rect(xoff-20,40,15*grid+20,80); } } } class Button { int x, y; int size; color basecolor, highlightcolor; color currentcolor; boolean over = false; boolean pressed = false; void update() { if(over()) { currentcolor = highlightcolor; } else { currentcolor = basecolor; } } boolean pressed() { if(over) { locked = true; return true; } else { locked = false; return false; } } boolean over() { return true; } boolean overRect(int x, int y, int width, int height) { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } } boolean overCircle(int x, int y, int diameter) { float disX = x - mouseX; float disY = y - mouseY; if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) { return true; } else { return false; } } } class CircleButton extends Button { CircleButton(int ix, int iy, int isize, color icolor, color ihighlight) { x = ix; y = iy; size = isize; basecolor = icolor; highlightcolor = ihighlight; currentcolor = basecolor; } boolean over() { if( overCircle(x, y, size) ) { over = true; return true; } else { over = false; return false; } } void display() { stroke(255); fill(currentcolor); ellipse(x, y, size, size); } } class RectButton extends Button { RectButton(int ix, int iy, int isize, color icolor, color ihighlight) { x = ix; y = iy; size = isize; basecolor = icolor; highlightcolor = ihighlight; currentcolor = basecolor; } boolean over() { if( overRect(x, y, size, size) ) { over = true; return true; } else { over = false; return false; } } void display() { stroke(255); fill(currentcolor); rect(x, y, size, size); } } void redogrid() { if(togglegrid) fill(255); else fill(0); stroke(255); rect(xoff,grid_ytop,grid*15,grid*10); int num; int denom; float sclhr; for ( int i = 0; i< images.length; i++ ) { counter=counterstart; for (int x = xoff; x < 16*grid; x=x+grid) { if(TimeDewArray[counter][i]<5) // if no values (or very close) then just draw outline { stroke(153); fill(0); rect(x,i*grid-1+grid_ytop,sz,sz); stroke(0,0); } else { if(togglegrid) tint(255,255,255,hrdewAlpha[counter][i]); else tint(colorArray[i][0],colorArray[i][1],colorArray[i][2],hrdewAlpha[counter][i]); image(images[i],x,i*grid+grid_ytop,sz,sz); } counter++; } } if(togglegrid) togglegrid = false; else if(!togglegrid) togglegrid = true; }