Hey all,
Ran into a little gotcha today, the title says it all - The "area" property of text in a screen won't respect the width and height provided unless the numbers are integers.
Does not work ( text will not wrap ):
text "Test" area (0, 0, 100.0, 100.0)
Does work ( text wraps ):
text "Test" area (0, 0, int(100.0), int(100.0))
Might be a nice to have fix by casting the width/height into ints by default in the text display code.
Text area does't respect width/height if given float values
- Divona
- Miko-Class Veteran
- Posts: 678
- Joined: Sun Jun 05, 2016 8:29 pm
- Completed: The Falconers: Moonlight
- Organization: Bionic Penguin
- itch: bionicpenguin
- Contact:
Re: Text area does't respect width/height if given float val
"area" always take tuple of integer values, as stated in the documentation.
Is there a reason why width and height has to be in float? There is no such thing as half a pixel in image resolution.
Is there a reason why width and height has to be in float? There is no such thing as half a pixel in image resolution.
Re: Text area does't respect width/height if given float val
Nope! No reason, just that its an invisible failure if you do end up using floats which might happen as a result of division if you're placing elements on screen programmatically rather than using exact coordinates. Its good that its in the documentation, but in absence of the documentation there's no clear indicator of whats going on and can potentially frustrate and waste time for developers. Its a small thing but I thought I'd point it out.
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3794
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Text area does't respect width/height if given float val
Ren'Py doesn't use subpixels?Divona wrote:There is no such thing as half a pixel in image resolution.
https://en.wikipedia.org/wiki/Sub-pixel_resolution
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Re: Text area does't respect width/height if given float val
The reason of that is that you already have "programmatical" size for containers.
Dividing a number by a number is not programmatical, is fixed math. You already knows all the values.
So, wanna divide the screen 3 part? Grid or hbox.
Wanna divide 1280 by 7? You end with floats. A no no in pixel.
@Imperf3kt: subpixeling is a way of rendering objects taking into account the difference into real size and screen resolution. It doesn't allow you to move something by "half pixel". It move by one, then the blit area get calculated in relation to the item size and screen resolution ("blurring" or averaging the edges of the item and faking your eyes)
Dividing a number by a number is not programmatical, is fixed math. You already knows all the values.
So, wanna divide the screen 3 part? Grid or hbox.
Wanna divide 1280 by 7? You end with floats. A no no in pixel.
@Imperf3kt: subpixeling is a way of rendering objects taking into account the difference into real size and screen resolution. It doesn't allow you to move something by "half pixel". It move by one, then the blit area get calculated in relation to the item size and screen resolution ("blurring" or averaging the edges of the item and faking your eyes)
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
10 ? "RENPY"
20 GOTO 10
RUN
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Text area does't respect width/height if given float val
Ren'Py tends to use floats to indicate "fraction of the available area". So when you give area (0, 0, 100.0, 100.0), you're really requesting 100x the space available.
Part of that was we didn't support subpixels back then. We actually do support subpixel now - Ren'Py is happy to put things on a pixel boundary. You have to cast to a special type called absolute, but pos (absolute(100.5), absolute(100.5)) will work fine.
Part of that was we didn't support subpixels back then. We actually do support subpixel now - Ren'Py is happy to put things on a pixel boundary. You have to cast to a special type called absolute, but pos (absolute(100.5), absolute(100.5)) will work fine.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Who is online
Users browsing this forum: No registered users