Add a Denominator to anchors (Default to 1) #12616
fcolecumberri
started this conversation in
GUI
Replies: 1 comment 3 replies
-
You can write |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the project you are working on
This applies to any GUI implementation.
Describe the problem or limitation you are having in your project
Trying to make an object be in the correct pixel position.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The idea is fairly simple, let's say you want to have a node starting at
1/3
from it's parent. for this you may use an anchor and put it to0.333
. however, the problem here is that1/3
!=0.333
so depending on the situation, stuff might get a pixel off (it could be 2 pixels in 4k resolution:3840*0.333 = 1278
!=3840/3 = 1280
). You could add more3333
but at some point, not adding 3s becomes an easy mistake to make.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The idea I propose is to make anchors fractions having 2 values, a
numerator
anddenominator
and calculate the position as(space*numerator)/denominator
so in cases werespace
anddenominator
share common factors those will naturally cancel out getting the closest value.Both values could still be
float
so if someone wants to make a weird value, that would be available.Is there a reason why this should be core and not an add-on in the asset library?
Because it's a modification of how the core works.
Beta Was this translation helpful? Give feedback.
All reactions