Resizing images in the gallery via the engine

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Pavel8694
Newbie
Posts: 4
Joined: Sat Aug 06, 2022 11:51 am
Completed: Gachimuchi: Become Dungeon Master, The Casino Incident.
Organization: Meme Corporation
itch: meme-corporation
Contact:

Resizing images in the gallery via the engine

#1 Post by Pavel8694 » Sat Aug 06, 2022 12:05 pm

Greetings to all!

I want to find out if there is any way to change the size of images in the gallery through the engine itself, using code. I understand that their size can be changed via Photoshop, but then they will decrease both on the PC version of the game and on the mobile. I would like to change their size exclusively for mobile devices, using code. I am not a programmer myself, so I cannot implement this feature.

I hope for your help and thank everyone who responds.

User avatar
m_from_space
Veteran
Posts: 302
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Resizing images in the gallery via the engine

#2 Post by m_from_space » Sun Aug 07, 2022 2:22 am

Depending on what you want, you can just easily use a transform like zoom or just set xsize and ysize.

Code: Select all

transform zm(z=0.5):
    zoom z

screen mygallery:
    vbox:
        add "myimage" at zm
        add "anotherimage" xsize 200 ysize 200
Another easy way would be to use the Frame() function, since it automatically resizes the containing image to the available area.
https://www.renpy.org/doc/html/displayables.html#Frame

User avatar
Pavel8694
Newbie
Posts: 4
Joined: Sat Aug 06, 2022 11:51 am
Completed: Gachimuchi: Become Dungeon Master, The Casino Incident.
Organization: Meme Corporation
itch: meme-corporation
Contact:

Re: Resizing images in the gallery via the engine

#3 Post by Pavel8694 » Sun Aug 07, 2022 12:26 pm

m_from_space wrote:
Sun Aug 07, 2022 2:22 am
Depending on what you want, you can just easily use a transform like zoom or just set xsize and ysize.

Code: Select all

transform zm(z=0.5):
    zoom z

screen mygallery:
    vbox:
        add "myimage" at zm
        add "anotherimage" xsize 200 ysize 200
Another easy way would be to use the Frame() function, since it automatically resizes the containing image to the available area.
https://www.renpy.org/doc/html/displayables.html#Frame
Thank you so much for your help! I decided to use the method with xsize and ysize for now:

Code: Select all

if renpy.variant("mobile"):
    add gl.make_button("horrorending", "horrorendinggallerypreview", xalign=0.5, yalign=3.0, hover_border="images/other/frame.png") xsize 430 ysize 252
    add gl.make_button("goodending", "theendgallerypreview", xalign=0.5, yalign=3.0, hover_border="images/other/frame.png") xsize 430 ysize 252
    add gl.make_button("neutralending", "neutralendinggallerypreview", xalign=0.5, yalign=3.0, hover_border="images/other/frame.png") xsize 430 ysize 252
    add gl.make_button("neutralending2", "neutralending2gallerypreview", xalign=0.5, yalign=6.5, hover_border="images/other/frame.png") xsize 430 ysize 252
    add gl.make_button("poster", "postergallerypreview", xalign=0.5, yalign=6.5, hover_border="images/other/frame.png") xsize 430 ysize 252
    add gl.make_button("bonus", "bonusgallerypreview", xalign=0.5, yalign=6.5, hover_border="images/other/frame.png") xsize 430 ysize 252
    null
This works well, but I'll still check the method with the Frame() function.

Once again, thank you for your help. Have a nice day!

Post Reply

Who is online

Users browsing this forum: mold.FF