xxxxxxxxxx
let numRectangles = 200; // Number of rectangles
let titleFont; // Custom font variable
let title = "Cosmic Kaleidoscope"; // Title text
let subtitle = "A Kaleidoscope of Colors"; // Subtitle text
function preload() {
titleFont = loadFont("BebasNeue-Regular.ttf"); // Load your custom font here
}
function setup() {
createCanvas(500, 700);
rectMode(CENTER);
angleMode(DEGREES);
noLoop();
}
function draw() {
background(0);
// Draw rectangles in random colors
for (let i = 0; i < numRectangles; i++) {
let r = random(50, 255);
let g = random(50, 255);
let b = random(50, 255);
fill(r, g, b, random(100, 200));
let rectSize = random(10, 50);
let x = random(width);
let y = random(height / 2, height);
rect(x, y, rectSize, rectSize);
}
// Text - Title
fill(255);
textFont(titleFont);
textSize(42);
textAlign(CENTER, CENTER);
text(title, width / 2, 50);
// Text - Subtitle
textSize(18);
text(subtitle, width / 2, 90);
}
function keyPressed() {
if (key === 'c' || key === 'C') {
redraw(); // Redraw when 'c' key is pressed to change the pattern randomly
}
if(key == 's') {
save('poster.png');
}
}