xxxxxxxxxx
124
function setup() {
createCanvas(600, 400);
landscape();
var landscapeButton = createButton("Generate a Landscape");
landscapeButton.mousePressed(landscape);
var saveButton = createButton("save image");
saveButton.mousePressed(saveImage);}
function saveImage(){
save("Landscape.png");}
function landscape() {
background("#FE9452");
noStroke();
textSize(30);
fill("#FFFFFF");
text('sunrise',300,180);
//cloud
for (var x = 50; x <= width; x +=130 ) {
var y = random(10,55);
cloud(x,y,"black");
var s = random(50,100); }
//cloud
// sun
for (var x = 150; x <= width; x +=600 ) {
var y = random(230,500);
sun(x,y,s); }
//sun
fill("black");
rect(0,300,width,100);
fill("#7B7B8B");
ellipse(100,330,500,60);
fill("#776F88")
ellipse(170,360,600,60);
fill("#7B7B8B")
ellipse(150,390,800,100);
// Head
stroke(1);
fill(255, 204, 153);
ellipse(410, 220, 40, 40); // Head at (x: 410, y: 220)
// Eyes
fill("black");
ellipse(400, 220, 4); // Left eye
ellipse(420, 220, 4); // Right eye
fill("rgb(227,105,126)")
ellipse(410,230,10)
// Body
fill(173, 216, 230);
rect(400, 240, 30, 60); // Body
// Left Leg
fill(0);
rect(400, 300, 8, 40); // Left leg
// Arms
fill(255);
rect(390, 240, 10,60); // Left arm
rect(420, 240, 10,60); // Right arm
// Right Leg
fill(0);
rect(412, 300, 8, 40); // Right leg
fill("black");
rect(385, 200,50,13);//Hat base
rect(400, 190, 20, 20); // Hat top
// Deck of the ship
noStroke();
fill("#7C351C")
arc(455, 270, 150,110, 0, PI);
// Mast of the ship
fill("#000000");
rect(450, 170, 10, 100);
// Sail of the ship
fill("red");
triangle(450, 160, 450, 220, 530, 195);
}
function cloud(x,y,c){
fill(c)
circle(x+20,y+20,50);
circle(x-20,y+20,50);
fill("#FE9452")
circle(x+20,y+30,50);
circle(x-20,y+30,50);
}
function sun(x,y){
fill("#FFDD7D");
circle(150,y,250);
}