xxxxxxxxxx
function setup() {
createCanvas(800, 800);
background(0); // Black background for a strong contrast
noLoop();
}
function draw() {
// Central figure - a simple rectangle structure to mimic the main character
fill(255); // White for central element
rectMode(CENTER);
rect(width / 2, height / 2, 80, 160);
// Bottom "legs"
fill(139, 69, 19); // Brown color
rect(width / 2 - 20, height / 2 + 100, 20, 80);
rect(width / 2 + 20, height / 2 + 100, 20, 80);
// Add colorful shapes around the central figure
for (let i = 0; i < 200; i++) {
let shapeSize = random(10, 30);
let x = random(width);
let y = random(height / 2, height); // Limit to bottom half for a bursting effect
// Random colors similar to the reference (yellow, red, green, blue)
let colors = [
color(255, 0, 0), // Red
color(0, 128, 0), // Green
color(0, 0, 255), // Blue
color(255, 255, 0) // Yellow
];
fill(random(colors));
// Randomly choose between a square and a circle
if (random(1) > 0.5) {
rect(x, y, shapeSize, shapeSize);
} else {
ellipse(x, y, shapeSize, shapeSize);
}
}
// Add smaller dots for extra visual interest
for (let j = 0; j < 100; j++) {
let dotSize = random(5, 15);
let x = random(width);
let y = random(height / 2, height);
fill(255, 165, 0, 150); // Semi-transparent orange for the dots
ellipse(x, y, dotSize, dotSize);
}
// Main text at the top
textAlign(CENTER, CENTER);
fill(255);
textSize(32);
text("Storico carnevale\ndi Ivrea", width / 2, 50);
textSize(24);
text("202a edizione", width / 2, 90);
text("21-22-23-24 febbraio 2009", width / 2, 120);
}
// Key press functionality for refreshing, saving, and clearing
function keyPressed() {
if (key == 'r' || key == 'R') {
draw(); // Redraw the canvas with random elements when 'r' is pressed
}
if (key == 's' || key == 'S') {
saveCanvas("zeyneperol.processing.jpg"); // Save the canvas as a .jpg file when 's' is pressed
}
if (key == 'k' || key == 'K') {
background(0); // Clear and reset the background to black
draw(); // Redraw the canvas to generate a new design
}
}