Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

scene: fix scaling of negative coordinates #3312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zsugabubus
Copy link

round() rounds away from zero that can cause unwanted lengthening of
dimensions when sides of box differ in their sign:

scale_length(2, -1, 1.5) == 4 (-1.5 -> -2; 1.5 -> 2)
scale_length(2, 1, 1.5) == 3

round() rounds away from zero that can cause unwanted lengthening of
dimensions when sides of box differ in their sign:

scale_length(2, -1, 1.5) == 4 (-1.5 -> -2; 1.5 -> 2)
scale_length(2,  1, 1.5) == 3
Copy link
Member

@vyivel vyivel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic seems right to me.

@emersion
Copy link
Member

Hm, maybe we could have a round_up function to make this more explicit?

@ascent12
Copy link
Member

I haven't really looked into the issue at all, but would using the other rounding functions like ceil()/floor()/trunc()/rint() work?

@zsugabubus
Copy link
Author

Sorry, I have made a big huge mistake here with truncation (towards zero) and adding half (scale = 1, offset < 0 => bleh).

Thinking it over, I would go with ceil(). It has the advantage over round() that moving a line on the screen, does not change its size.

@emersion
Copy link
Member

emersion commented Nov 1, 2021

wlroots has migrated to gitlab.freedesktop.org. This pull request has been moved to:

https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3312

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants