xxxxxxxxxx
33
// fraction sizes relative to width.
let ratio = 16/9;
let buttonSize = 0.1;
let button1X = 0;
let button1Y = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
video = createVideo(['assets/video.mp4']);
video.elt.setAttribute("playsinline", "");
}
function draw() {
let modX = 0;
let modY = 0;
console.log("width", width/height, ratio)
if(width / height < ratio) {
modY = height/2-(height*(width/height)/ratio)/2;
} else {
modX = width/2-(width/((width/height)/ratio))/2;
}
// console.log(mod)
noFill()
stroke(255,0,0)
square(width * button1X+modX, height * button1Y + modY, width * buttonSize);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}