rounded rectangle graphics#2491
Conversation
|
I don't think this approach is flexible enough. For example, I would expect drawing a square with a very high border radius to result in a circle. This is what happens in For example, here's the result of drawing |
|
Hmm, so what should flexible solution do instead? |
It looks like, at the very least, you want something like: radius = min(radius, min(height / 2, width / 2))See:
It would also be nice to be able to specify horizontal and vertical radius, and to specify individual radii for each of the 4 corners, by using or extending the existing |
|
One commit implement just min check, other use Radius as argument, so it is possible to specify different radius for each corner. |
| /// top-left, top-right, bottom-right, bottom-left. | ||
| #[derive(Debug, Clone, Copy, PartialEq, Default)] | ||
| pub struct Radius([f32; 4]); | ||
| pub struct Radius(pub [f32; 4]); |
There was a problem hiding this comment.
I don't think this needs to be pub — the from() methods can be used.
There was a problem hiding this comment.
Sorry, you are right. Fixed.
| } | ||
|
|
||
| /// Creates a new [`Path`] representing a rounded rectangle given its top-left | ||
| /// corner coordinate, its `Size` and radius. |
There was a problem hiding this comment.
Maybe:
its [`Size`] and border [`Radius`]
| } | ||
|
|
||
| /// Adds a rounded rectangle to the [`Path`] given its top-left | ||
| /// corner coordinate its `Size` and curve radius. |
There was a problem hiding this comment.
Maybe:
its [`Size`] and border [`Radius`]
|
This looks okay to me right now, but I'm not a maintainer so you'll have to wait for one to look at this. |
hecrj
left a comment
There was a problem hiding this comment.
Thanks!
I have removed the example since we already have too many.

This is my attempt to add functionality for additional canvas shape, rounded rectangle.