-
Notifications
You must be signed in to change notification settings - Fork 137
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 draw_blurred_rounded_rect_in
(intended for box shadows)
#700
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.
Very cool! Just a couple comment suggestions.
Co-authored-by: Raph Levien <[email protected]>
I was intending to do a proper review, but my comments would be:
Finally a question:
|
|
Awesome.
Excellent, I'll try this soon :)
Perhaps instead of some generic/composable utility in kurbo there ought to some super-simple |
Again, I don't really see the advantage of that - that was part of my original implementation, but I removed it for simplicity. As you say, that wouldn't work for inset shadows; I don't really think it is very useful. |
My motivation for such a feature is that: let kernel_size = 2.5 * std_dev;
let shape = BezPath::from_iter(
rect.inflate(kernel_size, kernel_size)
.path_elements(0.1)
.chain(
RoundedRect::from_rect(rect, radius)
.to_path(0.1)
.reverse_subpaths(),
),
); is not particularly simple or obvious to construct to those without knowledge of vector graphics who just want to a draw a box shadow with sensible defaults. It also requires quite a strong knowledge of kurbo to get it that simple (consider the code we currently have in Blitz for this). As the shape can be derived from the rect and shadow parameters, it would be convenient if there was a method that encapsulated that knowledge. Then the API for consumers of Vello would be the same simpler API as that of But eh, it's not the most important thing in the world. As-is, this seems like a nice improvement on what we had before. |
This avoids needing a clip layer for a rounded rectangle which doesn't need to draw the inner parts (e.g. a transparent background with a box shadow).
The previous test image was oversized, so this also fixes that (and makes any future such image fail the tests as expected). I imagine that the author of that test manually copied the value into the place, not realising the size of the image.