Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function drawBackground() {
- background(Koji.config.general.backgroundColor);
- if (imgBackground) {
- const originalRatios = {
- width: width / imgBackground.width,
- height: height / imgBackground.height
- };
- const coverRatio = Math.max(originalRatios.width, originalRatios.height);
- const newImageWidth = imgBackground.width * coverRatio;
- const newImageHeight = imgBackground.height * coverRatio;
- image(imgBackground, width / 2 - newImageWidth / 2, height / 2 - newImageHeight / 2, newImageWidth, newImageHeight);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement