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.
Sizing image automatically
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.
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.
-
- Regular
- Posts: 80
- Joined: Thu Dec 31, 2020 3:37 pm
- Contact:
- Ocelot
- Lemma-Class Veteran
- Posts: 2437
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Sizing image automatically
add a frame around what text in say screen and assign Borders with your image to it. Frames resize to fit child automatically.
< < insert Rick Cook quote here > >
-
- Regular
- Posts: 80
- Joined: Thu Dec 31, 2020 3:37 pm
- Contact:
Re: Sizing image automatically
Ooh, didn't know that. Thanks
-
- Regular
- Posts: 80
- Joined: Thu Dec 31, 2020 3:37 pm
- Contact:
Re: Sizing image automatically
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...
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...
- Ocelot
- Lemma-Class Veteran
- Posts: 2437
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Sizing image automatically
Here is the say screen I used:
Here is the image I used:
Here how is it looks:
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 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...
< < insert Rick Cook quote here > >
-
- Regular
- Posts: 80
- Joined: Thu Dec 31, 2020 3:37 pm
- Contact:
Re: Sizing image automatically
This works perfectly, thank you so much.
Who is online
Users browsing this forum: JosephGray