int px;
int py;
boolean germanated = false;
void setup() {
size(592, 376);
BImage b;
// b = loadImage("desert.jpg");
background(120); // replaced images with grey background
}
void loop(){
if(germanated){
Clover c1 = new Clover(int(random(0,6)), px, py);
c1.drawClover();
px = px + int(random(-20, 20));
py = py + int(random(-20, 20));
if (py > 180){
px = px + int(random(-20, 20));
}
println("X: " +px);
println("Y: " +py);
delay(100);
}
}
class Clover {
float thickness;
float shadeGreen;
float startX;
float startY;
float tallness;
float halfBase;
float baseY1;
float baseY2;
float baseX1;
float baseX2;
Clover(int s, int x, int y) {
startX = x;
startY = y;
if(startX < 180 && startY > 260 && startY < 295) {
startX = random(0, 768);
startY = random(180, 376);
}
tallness = s;
halfBase =tan(22.5)*tallness;
baseY1 = startY + halfBase;
baseY2 = startY - halfBase;
baseX1 = startX + halfBase;
baseX2 = startX - halfBase;
shadeGreen = random(100,255);
thickness = tallness/15;
}
void drawClover() {
strokeWeight(thickness);
stroke(150, 230, 150);
fill(00, shadeGreen, 00);
triangle(startX, startY, baseX1, startY - tallness + 2, baseX2, startY - tallness + 2);//North Triangle
triangle(startX, startY, startX + tallness, baseY1, startX + tallness, baseY2 + 2);//East Triangle
triangle(startX, startY, baseX1 +1, startY + tallness + 1, baseX2 + 1, startY + tallness + 1);//South Triangle
triangle(startX, startY, startX - tallness, baseY1, startX - tallness, baseY2 + 2);//West Triangle
}
void newColor() {
shadeGreen= random(100,255);
}
}
void mousePressed() {
germanated = true;
px = mouseX;
py = mouseY;
println("X: " +px);
println("Y: " +py);
}