Skip to content

IconManager preserve aspect ratio when auto packing#7651

Merged
Pessimistress merged 1 commit intomasterfrom
x/icon-auto-size
Feb 16, 2023
Merged

IconManager preserve aspect ratio when auto packing#7651
Pessimistress merged 1 commit intomasterfrom
x/icon-auto-size

Conversation

@Pessimistress
Copy link
Collaborator

Background

This issue has been raised in the Slack channel:

When using the IconLayer with auto packing, the application may not know the dimensions of an icon before loading it. Providing the wrong width/height will cause the rendered icon to be stretched.

After this PR, the IconManager preserves the aspect ratio of the incoming icon image while resizing.

This is technically a breaking change with no way of reverting to the old behavior. I would argue that it is the expected behavior, though.

Other caveats:

  • The packing algorithm is still run before any icon is loaded using the user-provided width/height, so there may end up being some empty pixels in the texture when all is loaded. However, this way we only have to resize the texture once.
  • If an icon image's aspect ratio is different from the pre-defined dimension, the pixels are centered in the provided bounding box. The default anchorX/anchorY (center of bounding box) will not be affected, but other values may appear off.

Change List

  • IconManager preserve aspect ratio when auto packing
  • Unit test

@coveralls
Copy link

Coverage Status

Coverage: 90.198% (+0.07%) from 90.133% when pulling c364817 on x/icon-auto-size into 78a6887 on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants