xxxxxxxxxx
69
// here is a comment
/*
This is a multi-line comment
p5 intro
by Carlos Brito
11/3/2024
a lesson on p5 functions and shapes
*/
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
colorMode(HSB);
fill(260, 70 , 100);
strokeWeight(3)
//Shapes
//ears
triangle(
200 - 20, 200 - 30, // x1, y1
200 - 20, 200, // x2, y2
200, 200 // x3 , y3
);
triangle(
200 + 20, 200 - 30, // x1, y1
200 + 20, 200, // x2, y2
200, 200 // x3 , y3
);
rectMode(CENTER)
square(200, 200, 40, 10);
//Eyes
fill("blue");
circle(200 -10 , 200 - 10 , 10);
circle(200 +10 , 200 - 10 , 10);
//Mouth
line(200 - 5, 200 + 5, 200 + 5, 200 + 10);
line(200 - 5, 200 + 10, 200 + 5, 200 + 5);
//feet
rect(200 - 10 , 200 + 30, 12, 8, 4);
rect(200 + 10 , 200 + 30, 12, 8, 4);
}
// save an image of the canvas
function mousePressed() {
save("character.jpg");
}