/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.u2paszmTVHc/rev.8
*
* authors:
* GoToLoop
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/**
* Raining Cloud (v2.51)
* by Jam131 (2014/Jan)
* mod GoToLoop & Poersch
*
* forum.processing.org/two/discussion/2747/
* how-to-spawn-an-object-at-mousex-but-make-it-not-move-with-cursor
*
* studio.processingtogether.com/sp/pad/export/ro.9l84$2z--gWui/latest
*/
static final int MIN_DIM = 3, MAX_DIM = 6;
static final int MIN_SPD = 4, MAX_SPD = 8;
static final short CLOUD_Y = 50;
static final short CLOUD_D = 0200, CLOUD_R = CLOUD_D>>1;
static final color CLOUD_C = 0340;
static final int NUM = 0100;
final Drop[] drops = new Drop[NUM];
void setup() {
size(800, 300, JAVA2D);
frameRate(60);
smooth(4);
noCursor();
noStroke();
colorMode(RGB, 0xFF);
ellipseMode(CENTER);
createDrops();
}
void createDrops() {
for ( int i = 0; i != NUM;
drops[i++] = new Drop(random(-CLOUD_R, CLOUD_R),
random(height - CLOUD_Y),
random(MIN_DIM, MAX_DIM),
random(MIN_SPD, MAX_SPD)) );
}
void draw() {
//clear(); // Java
background(0); // JS
fill(Drop.COLOUR);
for (Drop d: drops) d.script();
displayCloud();
}
void displayCloud() {
fill(CLOUD_C);
ellipse(mouseX, CLOUD_Y, CLOUD_D, 045);
ellipse(mouseX, CLOUD_Y - 010, 055, 055);
ellipse(mouseX + 040, CLOUD_Y - 015, 065, 065);
}
class Drop {
static final color COLOUR = #50D0E0;
short x, off;
float y;
final short dim;
final float spd;
Drop(float px, float py, float diam, float vel) {
x = off = (short) px;
y = py;
dim = (short) diam;
spd = vel;
}
void script() {
display();
update();
}
void display() {
ellipse(x, y, dim, dim);
}
void update() {
if ((y += spd) > height) {
y = CLOUD_Y;
x = (short) (mouseX + off);
}
}
}