xxxxxxxxxx
let crossPoint;
let hue=0;
let framecount = 0;
let freqencyOfWhite=0.618;
let firstColor;
let secondColor;
let delta;
let topLeftToBottomRight = true;
function setup() {
createCanvas(400, 400);
frameRate(60);
colorMode(HSB,360,100,100,100);
background(0,0,100,100);
stroke(0,0,0);
}
function draw() {
if (framecount % 60 === 0) {
firstColor = randomColor(freqencyOfWhite);
secondColor = randomColor(freqencyOfWhite);
delta= 2 + 5* random();
crossPoint = createVector(random(width),random(height));
topLeftToBottomRight= !topLeftToBottomRight;
}
if(topLeftToBottomRight) {
fill(firstColor);
rect(0,0,crossPoint.x,crossPoint.y);
fill(secondColor);
rect(crossPoint.x,crossPoint.y,width,height);
} else {
fill(firstColor);
rect(crossPoint.x,0,width,crossPoint.y);
fill(secondColor);
rect(0,crossPoint.y,crossPoint.x,height);
}
cross(crossPoint,delta);
framecount++;
}
function keyTyped() {
if (key === 's'){
save("AfterModrian.png");
}
}
function randomColor(frequencyOfWhite) {
let pallet = [10, 50, 210];
if(random(1)>frequencyOfWhite) {
return color( pallet[int(random(3))],100,100,20);
} else {
return color(0,0,100,20);
}
}
function cross(crossPoint, thickness) {
strokeWeight(thickness);
stroke(0,0,0,20);
line(0,crossPoint.y,width ,crossPoint.y);
line(crossPoint.x,0, crossPoint.x ,width);
}