I making a clock. I hope to make it a screen saver (someday).
// Problem: When Maximized, the ‘background()’ is slightly too large for the
// screen and I get unwanted scrollbars.
// When in fullscreen, I get no scrollbars but I get a ~100 pixel high white
// area at the bottom of the screen. The background is now not tall enough.
// Solution(part 1): DEMO of fullscreen (F11) background without scroll bars.
// I used ‘windowWidth’ to keep box centered when window is resized and I made
// windowWidth and windowHeight smaller by 6 pixels.
// Solution(part2): To remove the large white area at the bottom of the screen when in
// fullscreen (F11), I replaced line in HTML code:
// <body style="background-color:black;">
// and the white area at bottom of the screen went away.
// Tested in in Linux Mint 19, Firefox 63.0.3, Chromium v 70.0.3538.110 and Codepen(sort of).
//
var i = 6; //change to '0' to get unwanted scrollbars
function setup() {
createCanvas(windowWidth-i,windowHeight-i);
frameRate(1); // saves my poor old processor
}
function draw() {
background(0); // doesn't quite work in fullscreen (F11).
// ...but Still needed to cleanup when resizing
var xd = (windowWidth-i) / 2 - 400 / 2 ; // center the blue circle.
var yd = (windowHeight-i) / 2 - 400 / 2;
translate(xd, yd);
fill(0, 0, 160);
ellipse(200,200,400,400);
// removed the clock stuff for brevity.
}
I’m new to this so please let me know if I missed something somewhere. Thanks.