HW#5B
//FAN LAN
//HW#5B
//September 18, 2019
void setup() {
size(600, 480);
//background(255, 208, 126);
noStroke();
smooth();
}
void draw() {
background(204);
randomSeed(0);
for (int i = 20; i < width; i += 40) {
int green = int(random(0, 150));
float scalar = random(0.25, 1.0);
drawTree(i, 110, green, scalar);
}
}
void drawTree(int x, int y, int green, float s) {
pushMatrix();
translate(x, y);
scale(s); // Set the float sacle
//draw trunk
color trunkcolor = color(161, 113, 64);
fill(trunkcolor);
rectMode(RADIUS);
int a=50;
int b=320;
rectMode(RADIUS);
int trunkWeight=6;
int trunkHeight=35;
rect(a, b, trunkWeight, trunkHeight);
//draw canopy
color r = color(green, 117, 54);
fill(r); // Set the green value
int c=50;
int CanopyRadius=50; //canopy size
int d=300;
ellipse(c, d, CanopyRadius, CanopyRadius);
popMatrix();
}
Comments
Post a Comment