void drawFish(int x, int y, float scale) {
// fish tail
fill(random(255), random(255), random(255));
noStroke();
//stroke(0);
//strokeWeight(1);
triangle(x, y,
x + scale * 4, y + scale * 3,
x, y + scale * 6);
// fish body
//fill(random(255), random(255), random(255));
float centerOfBodyX = x + scale * 8;
float centerOfBodyY = y + scale * 2;
ellipse(centerOfBodyX, centerOfBodyY, 9 * scale, 7 * scale);
// fish eye
fill(0);
ellipse(centerOfBodyX + scale * 3, centerOfBodyY + scale * -1, .5 * scale, .5 * scale);
drawBubble(x + scale * 16, y + scale * 3, scale);
drawBubble(x + scale * 20, y, scale * 2.0);
}
void drawBubble(float x, float y, float scale) {
fill(204, 255, 255, 128);
noStroke();
ellipse(x, y, 3 * scale, 3 * scale);
}
void drawOcean() {
background(0);
fill(109, 219, 236);
noStroke();
rect(0, 0, 500, 500);
// hook 1
stroke(166, 192, 192);
strokeWeight(4);
arc(101, 65, 50, 70, 0, PI/2);
line(100, 0, 100, 100);
// hook 2
arc(339, 165, 50, 70, PI/2, PI);
line(340, 0, 340, 200);
// hook 3
arc(291, 350, 50, 70, 0, PI/2);
line(290, 0, 290, 385);
}
void setup(){
size(500,500);
}
void draw(){
drawOcean();
// For loop:
for (int i = 0; i < 20; i++) {
drawFish(int(random(500)), int(random(500)), 2 + random(3));
}
// While loop:
int i = 0;
while (i < 20) {
drawFish(int(random(500)), int(random(500)), 2 + random(3));
i++;
}
/*
for(INIT; TEST; UPDATE) {
...
}
INIT;
while (TEST) {
...
UPDATE;
}
*/
noLoop();
}