Skip to content
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

Support images with rounded corners #3257

Merged
merged 4 commits into from
Aug 15, 2023
Merged

Support images with rounded corners #3257

merged 4 commits into from
Aug 15, 2023

Conversation

emilk
Copy link
Owner

@emilk emilk commented Aug 14, 2023

You can now control the rounding of images using Image::rounding. This is implemented by augmenting RectShape with texture support. The corners are anti-aliased.

Example output:
image

@emilk emilk changed the title Support images with rounded corners Image::rounding to support images with rounded corners Support images with rounded corners Aug 14, 2023
Copy link
Collaborator

@abey79 abey79 left a comment

Choose a reason for hiding this comment

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

So timely :) Looks great 👍🏻

///
/// To display a texture, set [`Self::fill_texture_id`],
/// and set this to `Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0))`.
pub uv: Rect,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume this is to spare the Option on fill_texture_id, and the assorted 1 byte + padding impact on the struct size?

Copy link
Owner Author

Choose a reason for hiding this comment

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

That, and for symmetry with the backend where the top-left texel of the default texture is always white

@emilk emilk merged commit 3c4223c into master Aug 15, 2023
36 checks passed
@emilk emilk deleted the emilk/rounded-image branch August 15, 2023 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make rounded corners clip the image in ImageButton
2 participants