xxxxxxxxxx
/*
Ruth #WCCChallenge Typewriter Art 250325
https://openprocessing.org/sketch/2591450
#generativeart #creativecoding #p5js
Dear Raph and creative coding community,
inspired by "Series Towers" from Ruth Wolf-Reinhardt († 26. 02.2024)
https://images.app.goo.gl/eVthz75tixQBVESC9
- Added rotation and varying heights and numbers.
- Sadly flickering during rotation, as no real shading is implemented
pseudo-shading in Sechskant.shape() #49ff
- There also a polygon is created, which sets the specific char on the page
via testing each char position (center) is in the polygon
Join the Birb's Nest Discord for friendly creative coding community
and future challenges and contributions: https://discord.gg/S8c7qcjw2b
WCCC-Contributions: https://openprocessing.org/curation/78544
*/
let page, sechskante;
// sizes for page
const mar = 15;
let ts = (210 - mar - mar) / 60;
const nx = Math.ceil((210 - mar - mar) / ts);
const ny = Math.ceil((297 - mar - mar) / ts);
function setup() {
let sclX = windowWidth / 210;
let sclY = windowHeight / 297;
scl = min(sclX, sclY);
createCanvas(210 * scl, 297 * scl); // windowWidth, windowHeight
describe("Hommage to Ruth Wolf-Reinhardt, Series Towers");
frameRate(10);
stroke(32);
page = new Page(nx, ny, mar * scl, ts * scl);
makeObjects(scl);
}
function draw() {
background("rgb(252,246,239)");
page.init();
// sechskante[0].show();
for (const sechskant of sechskante) {
sechskant.show();
}
page.show();
noFill();
}
function mousePressed() {
if (mouseButton != RIGHT) setup();
}
function makeObjects(scl) {
// define number of objects
const num = ~~random(1, 6);
// get different heights for each object
let skHeights = [], sumHeights = 0;
for (let i = 0; i < num; i++) {
skHeights[i] = random(0.2, 1);
sumHeights += skHeights[i];
}
sumHeights *= 1.4; // correct / reduce heights to fit in page (with margins)
for (let i = 0; i < num; i++) {
skHeights[i] /= sumHeights;
}
// console.log(skHeights);
// define objects with corresponding heights
let totalHeight = height - 2 * mar * scl;
let currentY = height - mar * scl;
let maxWF = 0.4;
let currWF = maxWF;
// console.log(totalHeight, currentY);
sechskante = [];
let lastY;
for (let i = 0; i < num; i++) {
const currH = skHeights[i] * totalHeight;
let rx = width * currWF, ry = rx / 2;
if (i === 0) {
currentY -= currH/2 + ry;
} else {
currentY = lastY - currH / 2;
}
lastY = currentY - currH / 2;
sechskante.push(
new Sechskant(width / 2, currentY, rx, ry, currH)
);
currWF -= maxWF / num; // reduce width
} // create sechskants
}