/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://dflab.sketchpad.cc/sp/pad/view/ro.U6qGk4pBeyx/rev.189
*
* authors:
* Joao Serrano
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// This sketch builds on a prior work, "07 - Aleatoriedade", created by Pedro Ângelo
// http://dflab.sketchpad.cc/sp/pad/view/ro.9DrvlXt4IEC1-C/rev.386
// o movimento aleatório é característico de certos objectos
// (fumo, insectos), etc. e pode ser simulado usando a função random()
float px;
float py;
float jump = 100;
void setup() {
size(300, 300);
background(70,70,90);
px = random (width);
py = random (height);
}
// as instruções que estiverem dentro desta função draw
// são executadas a cada novo frame
void draw() {
float npx = constrain (px + random (-jump, jump), 40, width);
float npy = constrain (py + random (-jump, jump), 100, height);
fill(230,210,0,25);
noStroke();
rect (px, py, npx, npy);
float npx = constrain (px + random (-jump, jump), 20, width);
float npy = constrain (py + random (-jump, jump), 100, height);
fill(255,0,0,10);
noStroke();
ellipse (px, py, npx, npy);
px = npx;
py = npy;
}