xxxxxxxxxx
71
// Suprematism (Genuary 11 prompt)
// Inspired by by the paintings of Kasimir Malevitch
// Nicolas Lebrun @nclslbrn https://nicolas-lebrun.fr
const palettes = [
'#E9F8F6, #F1FAFD, #246023, #161922, #EA1703,#0C080B,#0173BB,#8B3014,#EEA600',
'#CED3D5, #FAF9E6, #5C4973, #1B0811,#321D19,#F4C808,#6487EE',
]
let ctr = {x: window.innerWidth /2, y: window.innerHeight/2 }
let minD = Math.min(window.innerWidth, window.innerHeight) /2
function setup() {
createCanvas(window.innerWidth, window.innerHeight)
pixelDensity(1)
noLoop()
rectMode(RADIUS)
composition();
fill(255, 200);
rect(width/2, height/2, width*0.3, height*0.1);
fill("#333")
textSize(24);
textAlign(CENTER);
text("Click to regenerate a composition", width/2, height/2);
}
function composition() {
let palette = random(palettes).split(',')
const textureColor = palette[0]
const compAngle = HALF_PI * random()
const textureThreshold = random(0.05, 0.2)
palette.splice(0, 1)
noStroke()
background(palette[0])
for (let i = 0; i < 20 + Math.round(random() * 30); i++) {
const pos = createVector(
(random() - 0.5) * minD * 0.9,
(random() - 0.5) * minD * 0.9
)
const shapeSize = createVector(
Math.max(ctr.x * 0.005, minD * random() * 0.5),
Math.max(ctr.y * 0.0001, minD * random() * 0.07)
)
fill(palette[i % palette.length])
push()
translate(ctr.x, ctr.y)
rotate(compAngle + TWO_PI / Math.ceil(random() * 3))
push()
translate(pos.x, pos.y)
rect(0, 0, shapeSize.x, shapeSize.y)
pop()
pop()
}
fill(textureColor)
for (let x = 0; x < window.innerWidth; x += 2) {
for (let y = 0; y < window.innerHeight; y += 2) {
if(Math.random() < textureThreshold) ellipse(x, y, 0.65)
}
}
}
function mouseClicked() {
composition()
}
function keyPressed() {
save('Genuary-11-suprematism')
}