-
Notifications
You must be signed in to change notification settings - Fork 150
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
Rounded corners on rectangles and images #672
Comments
Interesting, how would you expect this to work? Perhaps a function taking a normal rectangular image and then giving it a background color or 0-opacity around the corners at a given radius? Something like: fn border_radius<P>(image: &Image<P>, border_radius: f32) -> Image<P> {
...
} Or maybe an explicit background pixel: fn border_radius<P>(image: &Image<P>, border_radius: f32, background_pixel: P) -> Image<P> {
...
} Or if fn border_radius<P>(image: &Image<P>, border_radius: f32, background_pixel: P) -> Image<P>
where P: HasAlpha
{
...
} |
Personally, in my opinion, one border_radius applied to all corners is enough. But css (and some other rust libraries) support border radius on individual corners, i.e. |
Yep that sounds reasonable, so something like: //copied from kurbo
pub struct RoundedRectRadii {
pub top_left: f64,
pub top_right: f64,
pub bottom_right: f64,
pub bottom_left: f64,
}
pub fn rounded_corners<P>(image: &Image, rounded_rect_radii: RoundedRectRadii) -> Image<P>
where P: HasAlpha
{
...
} I must admit this kind of function isn't that high of a priority for me personally, but I have no problems with it being added to the library were someone to make a PR. |
Thanks, for now I'll just get the task at hand done with a quick and dirty hack using a custom background png. I'll poke around in the code later and see how hard/easy it might be for me to look at. |
This library is awesome, thanks for all your work on this.
Is it correct to say it's not possible to create a "rounded rect" or "rounded image" (i.e. like CSS border-radius)? Or is it possible and I have missed it?
Can I put in a vote for this one.
The text was updated successfully, but these errors were encountered: