Page 1 of 1
Sizing image automatically
Posted: Thu Jul 29, 2021 12:20 pm
by RewindTheGame
I'm trying to display a background image in my say window which would automatically size to the width of the text - or if that's not possible, I'd be happy to specify the width of the image every time. The image is just a simple one pixel border to go around the text, so by resizing the width I'd avoid having a massive gap between the right of the text and the right hand border of the image. What I want is something like:
add "gui/saybackground.png" width=150
Any ideas? It seems fairly reasonable to want a border that precisely surrounds the text.
Re: Sizing image automatically
Posted: Thu Jul 29, 2021 1:37 pm
by Ocelot
add a frame around what text in say screen and assign Borders with your image to it. Frames resize to fit child automatically.
Re: Sizing image automatically
Posted: Thu Jul 29, 2021 1:38 pm
by RewindTheGame
Ooh, didn't know that. Thanks
Re: Sizing image automatically
Posted: Thu Jul 29, 2021 2:09 pm
by RewindTheGame
Could you please give me an example of how to do this, as I can't read the RenPy documentation to save my life. None of it resembles anything close to English.
Suppose I have an image called "gui/textbox2.png" which I want to display on the say screen with the "what" text inside it and the image stretched/shrunk to fit exactly around the text. What code would I actually add to do that? Borders appears to be a function, which throws me completely. I thought it would be as simple as:
if who!="Nobox":
text what id "what"
else:
frame:
add "gui/textbox2.png"
ypos 100
xpos 100
text what id "what"
but that doesn't work.Also, how do I display these examples as code - there's no button in the editor for that...
Re: Sizing image automatically
Posted: Thu Jul 29, 2021 2:42 pm
by Ocelot
Here is the say screen I used:
Code: Select all
screen say(who, what):
style_prefix "say"
window:
id "window"
if who is not None:
window:
id "namebox"
style "namebox"
text who id "who"
frame:
xpos gui.dialogue_xpos
ypos gui.dialogue_ypos
background Frame("gui/im_border.png", Borders(10, 10, 10, 10))
padding (7, 7)
text what id "what" pos (0, 0)
Here is the image I used:
Here how is it looks:
RewindTheGame wrote: ↑Thu Jul 29, 2021 2:09 pm
how do I display these examples as code - there's no button in the editor for that...
Re: Sizing image automatically
Posted: Thu Jul 29, 2021 3:04 pm
by RewindTheGame
This works perfectly, thank you so much.