xxxxxxxxxx
// Another Parametric Cup Drawing in p5.js with variable shape, size, and color
let colors = ["#FF5733", "#33FF57", "#3357FF", "#FFD700", "#8A2BE2"];
function setup() {
createCanvas(400, 400);
noLoop();
}
function draw() {
background(240);
let cupColor = random(colors);
let handleColor = random(colors);
// Randomized cup dimensions
let cupWidth = random(70, 130);
let cupHeight = random(90, 160);
let cupX = width / 2;
let cupY = height / 2 + 20;
// Randomized handle dimensions
let handleWidth = random(25, 45);
let handleHeight = random(50, 80);
// Draw cup
fill(cupColor);
noStroke();
rectMode(CENTER);
rect(cupX, cupY, cupWidth, cupHeight, random(10, 20));
// Draw handle
fill(handleColor);
ellipse(cupX + cupWidth / 2 + handleWidth / 4, cupY, handleWidth, handleHeight);
// Draw cup rim
fill(200);
rect(cupX, cupY - cupHeight / 2 + 10, cupWidth - 10, 10, 5);
// Add a shadow for depth
fill(150, 150, 150, 50);
ellipse(cupX, cupY + cupHeight / 2, cupWidth * 1.2, 20);
}