Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const originalRatios = {
- width: window.innerWidth / imgBackground.width,
- height: window.innerHeight / imgBackground.height
- };
- const coverRatio = Math.max(originalRatios.width, originalRatios.height);
- const newImageWidth = imgBackground.width * coverRatio;
- const newImageHeight = imgBackground.height * coverRatio;
- //Draw image centered
- image(imgBackground, width / 2 - newImageWidth / 2, height / 2 - newImageHeight / 2, newImageWidth, newImageHeight);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement