-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add fitMode property on Image Elements. #4206
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few small comments, but this looks great!
If |
What do you mean by 'discarded'? Both |
I see, just on a screenshot in PR, it showed grey areas. |
Aahh right! Yea sorry those are just other image elements placed on top just to represent the actual bounds. I updated the description to try and explain that further. |
96d6f00
to
4d53f54
Compare
Fixes #3726
Adds a new property to
Element
component, used only onImage
:fitMode
. Set how the content should be fitted and preserve the aspect ratio of the source texture or sprite. (nomenclature is borrowed from https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit):stretch
(default;pc.FITMODE_STRETCH
): Fit the content exactly to the Element's bounding box.contain
(pc.FITMODE_CONTAIN
): Fit the content within the Element's bounding box while preserving its Aspect Ratio.cover
(pc.FITMODE_COVER
): Fit the content to cover the entire Element's bounding box while preserving its Aspect Ratio.the white boxes are other Image elements placed on top of the actual image and are there just to represent the actual bounds of each Element
Extra: Cover + Masking
The
cover
setting works very well with an additionalmask
Element
if the desired effect is to clip the content to only display the part inside the bounding box:I confirm I have read the contributing guidelines and signed the Contributor License Agreement.