xxxxxxxxxx
204
// Set up the canvas
function setup() {
createCanvas(400, 400);
}
// Draw function
function draw() {
background(220);
background("#88CAFE"); // Set background color
// Draw clouds
noStroke();
fill("#FFFFFF");
ellipse(50, 70, 50);
ellipse(85, 65, 50);
ellipse(85, 75, 50);
ellipse(115, 70, 50);
ellipse(330, 100, 50);
ellipse(300, 110, 50);
ellipse(265, 105, 50);
ellipse(295, 100, 50);
// Draw grass
fill(0, 150, 0); // Dark green for grass
rect(0, 300, width, height - 300); // Draw grass rectangle
// Draw sun
fill(255, 255, 0); // Yellow for sun
ellipse(190, 80, 80, 80); // Draw sun ellipse
// Draw flowers
stroke(1);
drawFlower(100, 320, 60, 80); // Draw first flower
drawFlower(200, 270, 70, 90); // Draw second flower
drawFlower(300, 330, 64, 84); // Draw third flower
}
// Function to draw a flower
function drawFlower(x, y, flowerWidth, flowerHeight) {
// Draw stem
fill(0, 200, 0); // Green for stem
rect(x - 5, y, 10, 100); // Draw stem rectangle
// Draw petals
fill(255, 100, 100); // Red for petals
ellipse(x, y, flowerWidth, flowerHeight); // Draw flower ellipse
ellipse(x - 30, y - 20, flowerWidth, flowerHeight); // Draw petal ellipse
ellipse(x + 30, y - 20, flowerWidth, flowerHeight); // Draw petal ellipse
ellipse(x - 30, y + 20, flowerWidth, flowerHeight); // Draw petal ellipse
ellipse(x + 30, y + 20, flowerWidth, flowerHeight); // Draw petal ellipse
// Draw center of flower
fill(255, 255, 0); // Yellow for center
ellipse(x, y, 40, 40); // Draw center ellipse
// Butterfly
var mouseXPosition = mouseX; // Mouse X position
var mouseYPosition = mouseY; // Mouse Y position
// Draw right wing
fill("#8257C5")
quad(mouseXPosition, mouseYPosition + 20, mouseXPosition + 30, mouseYPosition, mouseXPosition + 30, mouseYPosition + 48, mouseXPosition, mouseYPosition + 40);
fill("rgb(254,186,248)")
quad(mouseXPosition, mouseYPosition, mouseXPosition + 35, mouseYPosition - 10, mouseXPosition + 35, mouseYPosition + 35, mouseXPosition, mouseYPosition + 20);
// Draw left wing
fill("#8257C5")
quad(mouseXPosition, mouseYPosition + 20, mouseXPosition - 25, mouseYPosition + 10, mouseXPosition - 25, mouseYPosition + 48, mouseXPosition, mouseYPosition + 40);
fill("rgb(253,172,245)")
quad(mouseXPosition, mouseYPosition, mouseXPosition - 30, mouseYPosition - 10, mouseXPosition - 30, mouseYPosition + 30, mouseXPosition, mouseYPosition + 20);
// Draw face
fill("black");
rect(mouseXPosition, mouseYPosition - 10, 5, 52, 30);
// Draw eyes
fill("black")
ellipse(mouseXPosition - 10, mouseYPosition - 20, 7);
ellipse(mouseXPosition + 12, mouseYPosition - 20, 7);
stroke(3);
line(mouseXPosition + 1, mouseYPosition, mouseXPosition - 10, mouseYPosition - 20);
line(mouseXPosition + 5, mouseYPosition, mouseXPosition + 10, mouseYPosition - 20);
}
/*
function setup() {
createCanvas(400, 400);
}
function mousePressed() {
save('artwork.jpg'); }
function draw() {
background(220);
background("#88CAFE");
function mousePressed() {
save('artwork.jpg'); }
//Cloude
noStroke();
fill("#FFFFFF");
ellipse(50,70,50);
ellipse(85,65,50);
ellipse(85,75,50);
ellipse(115,70,50);
ellipse(330,100,50);
ellipse(300,110,50);
ellipse(265,105,50);
ellipse(295,100,50);
// Draw grass
fill(0, 150, 0); // Dark green for grass
rect(0, 300, width, height - 300); // Draw grass rectangle
// Draw sun
fill(255, 255, 0); // Yellow for sun
ellipse(190, 80, 80, 80); // Draw sun ellipse
// Draw flowers
stroke(1);
drawFlower(100, 320, 60 ); // Draw first flower
drawFlower(200, 270, 70); // Draw second flower
drawFlower(300, 330, 64 ); // Draw third flower
}
// Function to draw a flower
function drawFlower(x, y, flowerWidth, flowerHeight) {
// Draw stem
fill(0, 200, 0); // Green for stem
rect(x - 5, y, 10, 100); // Draw stem rectangle
// Draw petals
fill(255, 100, 100); // Red for petals
ellipse(x, y, flowerWidth, flowerHeight); // Draw flower ellipse
ellipse(x - 30, y - 20, flowerWidth, flowerHeight); // Draw petal ellipse
ellipse(x + 30, y - 20, flowerWidth, flowerHeight); // Draw petal ellipse
ellipse(x - 30, y + 20, flowerWidth, flowerHeight); // Draw petal ellipse
ellipse(x + 30, y + 20, flowerWidth, flowerHeight); // Draw petal ellipse
// Draw center of flower
fill(255, 255, 0); // Yellow for center
ellipse(x, y, 40, 40); // Draw center ellipse
/// Butterfly ********not a another name
var a= mouseX; // 100
var b= mouseY; // 100
//right wing
fill("#8257C5")
quad(a,b+20,a+30,b,a+30,b+48,a,b+40);
fill("rgb(254,186,248)")
quad(a,b,a+35,b-10,a+35,b+35,a,b+20);
//right wing backup
//fill("pink")
// quad(100,120,130,100,130,148,100,140);
//fill("red")
//quad(100,100,135,90,135,130,100,120);//
//left wing
fill("#8257C5")
quad(a,b+20,a-25,b+10,a-25,b+48,a,b+40);
fill("rgb(253,172,245)")
quad(a,b,a-30,b-10,a-30,b+30,a,b+20);
//left wing backup
//fill("pink")
//quad(100,120,75,110,75,148,100,140);
//fill("red")
//quad(100,100,70,90,70,130,100,120);
// face
fill("black");
rect(a,b-10,5,52,30);
//eye
fill("black")
ellipse(a-10,b-20,7);
ellipse(a+12,b-20,7);
stroke(3);
line(a+1,b,a-10,b-20);
line(a+5,b,a+10,b-20);
}
*/