/**
* RippleFX v1.0.0 by cdmb architects (cc) 2008
* The sketch let's you generate concetric ripples based
* on wave frequencies. Lower frequecies produce larger ripples.
*
* Use the scroll bars to adjust the variables.
* Use your mouse to draw:
* Press the left mous button to generate a ripple.
* Hold the mouse button down to intensifiy it.
* Move you mouse whil holding the button down to paint ripples.
* Release the mouse button to stop sketching.
*
* For further information and questions about RippleFX please
* take a look at the documentation, the examples, or the
* website at http://barlieb.com/index.php?option=com_content&task=view&id=75&Itemid=88
*
* key combinations:
* ALT+h hide and show controllers
* ALT+k bring the key menu to the front. use the arrow keys.
* Hold the ALT key and move controllers by dragging them.
*/
import controlP5.*;
ControlP5 controlP5;
float f = 31.5; // Wave Frequency
float n = 1500; // Number of ripples
void setup() {
size(500,500);
background(255);
frameRate(25);
controlP5 = new ControlP5(this);
controlP5.addSlider("wave frequency",0,400,f,1,50,400,12).setId(1);
controlP5.addSlider("number of ripples",0,2000,n,1,65,400,12).setId(2);
controlP5.setColorBackground(255);
controlP5.setColorForeground(0);
controlP5.setColorActive(0xffff0000);
controlP5.setColorLabel(0);
}
void controlEvent(ControlEvent theEvent) { // Controls the scrollbar and variables
println("got a control event from controller with id "+theEvent.controller().id());
switch(theEvent.controller().id()) {
case(1):
f = (float)(theEvent.controller().value());
break;
case(2):
n = (float)(theEvent.controller().value());
break;
}
}
void draw() {
noStroke(); // White Blockout Top Area
fill(255);
rect(0,0,500,77);
float c = 340.29; // Speed of sound at sea level
float w = c/f; // Wavelength
for (float i = w; i < n; i+=w) { // For Loop controls concetric ripples based on wavelengths
if(mousePressed) { // If mouse pressed the draw the concentric ripple
smooth();
noFill();
strokeWeight(0);
stroke(random(i),0,0,random(0,50));
ellipse(mouseX,mouseY,i,i);
}
else {
}
}
PFont font; // Prints all the info to the window.
font=loadFont("CourierNewPSMT-12.vlw");
textFont(font);
fill(0);
text("RippleFX v1.0.0 ",0,12);
text("cdmb architects (cc) 2008 ",0,24);
text("press/hold/move/release the mouse to sketch",0,40);
}