xxxxxxxxxx
69
// Use SCL to make a smaller version when testing on your laptop screen
let SCL = 1; //0.1;
let WIDTH = 1920;
// Barnard
let BOUNDARY = 1070;
let OVERLAP = 15;
let PHEIGHT = 1080 * 2;
let HEIGHT = PHEIGHT - OVERLAP;
let pg;
function setup() {
createCanvas(WIDTH * SCL, PHEIGHT * SCL);
//cnv1.hide();
pg = createGraphics(WIDTH, PHEIGHT);
pixelDensity(1);
//noStroke();
}
function draw() {
// Scales all of the drawing code
mouseX /= SCL;
mouseY /= SCL;
pg.background(0, 10);
pg.fill('blue');
// Use WIDTH and HEIGHT instead of width and height
// Or everything will be teeny-tiny!
pg.rect(WIDTH / 4, 0, 100, HEIGHT / 2);
pg.fill('green');
// Use WIDTH and HEIGHT instead of width and height
// Or everything will be teeny-tiny!
pg.rect(WIDTH / 4, HEIGHT / 2, 100, HEIGHT / 2);
pg.fill('red');
pg.ellipse(mouseX, mouseY, 100, 100);
pg.stroke('white');
pg.strokeWeight(10);
pg.line(0, HEIGHT / 2, WIDTH, HEIGHT / 2);
pg.noStroke();
for (let x = 0; x < WIDTH; x += WIDTH / 10) {
pg.rect(x, 0, 50, HEIGHT);
}
// Draw the off-screen buffer
//image(pg, 0, 0);
// Scale it down
scale(SCL, SCL);
blendProjectors();
}
// Do the projection blending
function blendProjectors() {
// Erase canvas
background(0);
// Draw the bottom half of the canvas, pushed down by the overlap
image(pg, 0, BOUNDARY + OVERLAP, WIDTH, BOUNDARY, 0, HEIGHT / 2, pg.width, BOUNDARY);
// Scale the top half up a little bit
let scl = 0.95;
scale(scl, scl);
// Shift it up
translate(0, -(scl-1)/scl * HEIGHT / 2);
// Draw the top half of the canvas
image(pg, 0, 0, WIDTH, BOUNDARY, 0, 0, pg.width, BOUNDARY);
}