xxxxxxxxxx
30
function setup() {
const canvasWidth = 800;
const canvasHeight = 600;
createCanvas(canvasWidth, canvasHeight);
}
function draw() {
background(220);
const x = 400;
const y = 300;
const rotation = PI / 4; // Rotate 45 degrees (in radians)
const bottomWidth = 50;
drawShape(x, y, rotation, bottomWidth, 50);
}
function drawShape(x, y, rotation, bottomWidth, triangleHeight) {
const shapeHeight = 100;
const topWidth = triangleHeight;
push();
translate(x, y);
rotate(rotation);
triangle(-bottomWidth / 2, shapeHeight / 2, -topWidth / 2, -shapeHeight / 2, topWidth / 2, -shapeHeight / 2);
pop();
}