xxxxxxxxxx
59
function setup() {
createCanvas(800, 600);
noLoop();
drawSky();
drawTrees();
drawGround();
}
function drawSky() {
for (let y = 0; y < height / 2; y++) {
let inter = map(y, 0, height / 2, 0, 1);
let c = lerpColor(color(150, 200, 255), color(200, 180, 220), inter);
stroke(c);
line(0, y, width, y);
}
noStroke();
fill(240, 240, 255, 180);
ellipse(200, 150, 250, 100);
ellipse(600, 100, 300, 120);
ellipse(400, 200, 200, 80);
}
function drawTrees() {
for (let i = 0; i < 20; i++) {
let x = random(50, width - 50);
let treeHeight = random(100, 250);
let leafSize = random(50, 100);
drawTree(x, height - 150, treeHeight, leafSize);
}
}
function drawTree(x, y, h, leafSize) {
stroke(90, 60, 30);
strokeWeight(10);
line(x, y, x, y - h);
fill(random(150, 255), random(80, 180), 0);
noStroke();
for (let i = 0; i < 8; i++) {
ellipse(x + random(-leafSize, leafSize), y - h + random(-leafSize, leafSize), leafSize, leafSize);
}
}
function drawGround() {
noStroke();
fill(150, 100, 50);
rect(0, height - 150, width, 150);
for (let i = 0; i < 100; i++) {
fill(130, 70, 30, 150);
ellipse(random(width), random(height - 100, height), random(20, 50), random(10, 30));
}
}