image fit for renpy

in #game5 years ago


here's two small functions that I'm going to use for my new renpy gallery, they are necessary for scaling images that are bigger than the screen.
since they can be useful for other uses as well I thought it would be a good idea to share it with my patreons and explain how to use it.

the get_image_size is simple, you'll give it an images address to get it's width and height in a tuple, here is the example you've seen in the video.
text str(get_image_size("img2.jpg"))

the image_fit needs the images address and the box size you want to fit the image in and returns the zoom level you need to fit the image to that box:
add "img2.jpg" zoom image_fit("img2.jpg", [1920,1080])
in this example the image will be fitted in the screen size that is 1920x1080

it also returns 1 to keep the image size the same if the images size is smaller than the given frame size, you can upscale the smaller images if needed by adding a 0 as a flag to the arguments.
add "img2.jpg" zoom image_fit("img2.jpg", [1920,1080], 0)

to get it and my other bits check my patreon:
https://www.patreon.com/KiaAzad
or leave a comment here.


▶️ DTube
▶️ IPFS
Sort:  

Your outstanding gaming content has caught our eyes and is rewarded with an upvote. Please visit our page @steemgg to learn more about Steemgg, the first html5 gaming platform built on the Steem Blockchain.

Thank you ^_^
I'll definitely check your discord

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.032
BTC 61383.17
ETH 2915.78
USDT 1.00
SBD 3.61