Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. function drawBackground() {
  2. background(Koji.config.general.backgroundColor);
  3.  
  4. if (imgBackground) {
  5. const originalRatios = {
  6. width: width / imgBackground.width,
  7. height: height / imgBackground.height
  8. };
  9.  
  10. const coverRatio = Math.max(originalRatios.width, originalRatios.height);
  11. const newImageWidth = imgBackground.width * coverRatio;
  12. const newImageHeight = imgBackground.height * coverRatio;
  13.  
  14. image(imgBackground, width / 2 - newImageWidth / 2, height / 2 - newImageHeight / 2, newImageWidth, newImageHeight);
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement