-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Taffy points actually seem to represent pixel sizes #236
Comments
Is this still the case for different monitor DPI values? |
I think it's better for Taffy to stay on something abstract like Points instead of something specific like Pixels. It's up to the user to decide what they will use |
@geom3trik Essentially Taffy just has one unit, along with percentages. As such, what that unit corresponds to is really up to the caller of the library who can use it to represent whatever they like. |
@mockersf I'm somewhat sympathetic to that point of view, however Taffy's |
For morphorm I used the pixels name but they actually represent logical points which are then scaled by DPI before being passed to the layout system. However, I'm considering changing it to points because now I'm wondering if both should exist. Points for when you want the logical pixels, and pixels for when you want physical pixels no matter the DPI. I don't know if this is a good idea or not but I noticed on a laptop I have with a 1.25 scale factor that things looked bad because often multiplying by that scale factor still results in fractional values. The other option is to always round to the nearest physical pixel but I'm not sure if that's the right solution or not. Hence the idea to provide points and pixels. |
Could you fix this by scaling before running through the layout computation (morphorm/taffy)?
I'm not sure if you currently do rounding on the logical pixels, but that's what Taffy does. It computes everything, and then the final step is a rounding pass. |
That's what I'm doing currently, but 1.25 is an awkward scale factor. Let's say you have 5px of space between elements, now it becomes 6.25 and you end up with some blurry edges from the AA. The more I think about it the more I think it probably should be rounded.
So there is some rounding already, but just for stretch/flexible space and size and for percentages. I didn't think pixels needed to be rounded because at the time I wrote it pixels meant pixels and not points. I think this distinction is important, so circling back to the original point of this issue, I think it should be kept as points in taffy (and morphorm should probably follow this). This does raise a question though, should the user be able to specify a dimension in actual pixels? |
…aphic points (fixes DioxusLabs#236)
…aphic points (fixes DioxusLabs#236)
Originally posted by @nicoburns in #232 (comment)
This is also how they're used upstream in Bevy.
The text was updated successfully, but these errors were encountered: