Text area does't respect width/height if given float values

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
User avatar
DizzyKa
Newbie
Posts: 15
Joined: Sat Sep 24, 2016 4:49 pm
Projects: @GossamerAcademy
Contact:

Text area does't respect width/height if given float values

#1 Post by DizzyKa »

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.

User avatar
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

#2 Post by Divona »

"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.
Completed:
Image

User avatar
DizzyKa
Newbie
Posts: 15
Joined: Sat Sep 24, 2016 4:49 pm
Projects: @GossamerAcademy
Contact:

Re: Text area does't respect width/height if given float val

#3 Post by DizzyKa »

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.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
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

#4 Post by Imperf3kt »

Divona wrote:There is no such thing as half a pixel in image resolution.
Ren'Py doesn't use subpixels?
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

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Text area does't respect width/height if given float val

#5 Post by gas »

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)
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

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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

#6 Post by PyTom »

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.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users