HW#4 revised
//FAN LAN
//HW#4 revised
//September 18, 2019
//for cloud movement
float circleX=0;
float xspeed = 10;
void setup() {
size(600, 600);
//background(255, 208, 126);
noStroke();
smooth();
}
void draw() {
drawSky();
drawLandform();
drawTrees();
drawSun();
drawClouds();
}
void drawSky() {
color skycolor = color(13, 238, 252); //use the colour yellow
fill(skycolor);
rect(0, 0, width, height/2);
}
void drawLandform() {
color landcolor = color(252, 252, 215);
fill(landcolor);
rect(height/2, 0, width, height/2);
}
void drawTrees() {
//draw trunk
color trunkcolor = color(161, 113, 64);
fill(trunkcolor);
rectMode(RADIUS);
for (int x=50; x < width-50; x+=70) {
int y=320;
rectMode(RADIUS);
int trunkWeight=6;
int trunkHeight=35;
rect(x, y, trunkWeight, trunkHeight);
}
//draw canopy
color canopycolor = color(99, 117, 54);
fill(canopycolor);
for (int x=50; x < width-50; x+=70) {
int CanopyRadius=50; //canopy size
int y=300;
ellipse(x, y, CanopyRadius, CanopyRadius);
}
}
void drawSun() {
fill (252, 130, 15);
int SunRadius=40;
ellipse(width/2, height/3, SunRadius, SunRadius);
}
void drawClouds() {
color white= color(255, 255, 255);
fill(white); //use the colour and draw clouds
int a=70; //radius of first ellipse
int b=90;//radius of second ellipse
int y=75;
ellipse(circleX+a/2, y, a, a);
ellipse(a+circleX, y, b, b);
ellipse(a+a/2+circleX, y, a, a);
circleX=circleX + xspeed;
if (circleX+a+a/2>width||circleX<0) {
xspeed=xspeed*-1; //turn around
}
}
Comments
Post a Comment