xxxxxxxxxx
40
/*
drawing with functions
3.24.2024
*/
function setup() {
createCanvas(600, 400);
landscape();
}
function landscape() {
background("lightblue");
fill("green");
noStroke();
rect(0, 300, width, 100);
for (var x = 0; x <= width; x += 50) {
var y = random(20, 140);
cloud(x, y, 'white');
var s = random(50, 100);
tree(x, 220, s);
}
// cloud(200, 50, 'gray');
// tree(200, 220, 100);
}
function cloud(x, y, c) {
fill(c);
circle(x, y, 50);
circle(x + 20, y + 20, 50);
circle(x - 20, y + 20, 50);
}
function tree(x, y, treeSize) {
fill('brown');
rect(x, y, 20, 100, 5);
fill('green');
circle(x + 10, y, treeSize);
}