/** * Pulses * *

Elie Zananiri
* CART 253, Winter 2008

*/ // ---------------------------------------------------------------------- // GLOBAL CONSTANTS // ---------------------------------------------------------------------- int SCALE = 10; // ---------------------------------------------------------------------- // GLOBAL VARIABLES // ---------------------------------------------------------------------- int x; // x-coordinate of the pulse int y; // y-coordinate of the pulse float s; // size of the pulse // ---------------------------------------------------------------------- // BUILT-IN FUNCTIONS // ---------------------------------------------------------------------- void setup() { size(400, 400); smooth(); noStroke(); } void draw() { background(0); // draw the pulse drawPulse(); } void mousePressed() { movePulse(mouseX, mouseY); } // ---------------------------------------------------------------------- // USER FUNCTIONS // ---------------------------------------------------------------------- /* draws a pulse and updates its size */ void drawPulse() { fill(255); ellipse(x, y, sin(s)*SCALE, sin(s)*SCALE); s += 0.1; } /* moves the pulse to the given position */ void movePulse(int newX, int newY) { x = newX; y = newY; }