xxxxxxxxxx
107
function setup() {
createCanvas(500, 500);
background(74, 139, 119);
// Dark green background
}
function mousePressed() {
save('artwork.jpg');
}
// Face
function draw() {
// Face
noStroke();
fill(250, 128, 114);
ellipse(260, 255, 130, 240);
// Eyes
fill(80, 30, 10);
ellipse(210, 220, 38, 25);
ellipse(310, 220, 38, 25);
// Pupils
noStroke();
fill(0);
ellipse(207, 222, 8, 8);
ellipse(306, 222, 8, 8);
// Mouth found through reference page
noStroke();
fill(255, 0, 255); // Fuchsia for the mouth
arc(260, 280, 40, 15, 0, PI + QUARTER_PI, CHORD);
// Nose First version
// Triangle
// fill(255, 200, 170);
// triangle(270, 238, 260, 255, 255, 238);
// Nose
fill(255, 200, 170);
rect(255, 235, 10, 30, 145); // Rounded nose
//the code below is Ai Generated
// Draw the buns using the function
drawBuns(210, 175, 30, 60, "left"); // Left bun
drawBuns(310, 175, 30, 60, "right"); // Right bun
}
// the code below is Ai Generated Define function to draw buns this
function drawBuns(centerX, centerY, width, height, side) {
// Set fill color for the buns (dark brown)
fill(65, 40, 14);
// Calculate base positions for left and right buns
const leftBaseX = side === "left" ? centerX - width / 2 : centerX + width / 2;
const rightBaseX =
side === "left" ? centerX + width / 2 : centerX - width / 2;
// Draw the main part of the bun (rounded rectangle)
rect(leftBaseX - width / 2, centerY - height / 2, width, height, 20); // Adjust corner radius as needed
// Draw the baseball cap using the function
drawBaseballCap(260, 200, 150, 80, 30, -PI / 6); // Adjust parameters as needed
}
// Define function to draw a baseball cap
function drawBaseballCap(
centerX,
centerY,
capWidth,
capHeight,
brimLength,
brimAngle
) {
// Set fill color for the cap (adjust as needed)
fill(255, 0, 255); // Red
// Calculate brim endpoint coordinates based on angle and length
const brimTipX = centerX + brimLength * cos(brimAngle);
const brimTipY = centerY + brimLength * sin(brimAngle);
// Draw the main part of the cap (rounded top)
ellipse(centerX, centerY - capHeight / 2, capWidth, capHeight);
// Draw the brim using two triangles for a smooth curve
beginShape();
// Connect cap edge to brim tip
vertex(centerX - capWidth / 2, centerY);
vertex(brimTipX, brimTipY);
// Connect brim tip to other side of cap edge
vertex(centerX + capWidth / 2, centerY);
endShape(CLOSE);
// Draw the button on the front (optional)
fill(153, 0, 153);
ellipse(centerX, centerY - (capHeight * 2) / 3, 10, 10);
// Draw the bike frame
fill(255, 165, 0); // Orange frame
rect(260, 350, 80, 50, 10); // Main body
// wheels
fill(0); // Black wheels
ellipse(275, 400, 30, 30); // Front wheel
ellipse(330, 400, 30, 30); // Back wheel
}