xxxxxxxxxx
52
var w,h;
var teal = "#43b8b0";
var p = 'left';
var result;
function setup() {
w = windowWidth;
h = windowHeight;
createCanvas(w, h);
}
function draw() {
background(0);
fill(teal);
noStroke();
if (p == "left") {
result = true;
rect(0, 0, width / 2, h);
} else {
result = false;
rect( width / 2, 0, width / 2, h);
}
fill(255);
text(`var position = "${p}";`, 15, 30);
text(`if(position == "left") {
...
}`, 15, 60);
text(`else {
...
}`, w/2+15, 60);
textFont("Fira Code");
textSize(16);
textAlign( CENTER);
text(result, w/4, h-30);
text(!result,3*w/4, h-30);
textAlign( LEFT);
line(w / 2, 0, w / 2, h);
strokeWeight(2);
}
function mouseMoved(){
if( mouseX > 0 && mouseX < w && mouseY > 0 && mouseY < h) {
p = constrain( mouseX, 0, w) / (w / 2) | 0
p = ['left', 'right'][p]
loop();
}
}
function windowResized() {
resizeCanvas(w, h);
};