Skip to content

Add BlurredRoundedRectangle - #173

Open
PoignardAzur wants to merge 2 commits into
linebender:mainfrom
PoignardAzur:blurred_rect
Open

Add BlurredRoundedRectangle#173
PoignardAzur wants to merge 2 commits into
linebender:mainfrom
PoignardAzur:blurred_rect

Conversation

@PoignardAzur

Copy link
Copy Markdown
Contributor

Copy-pasted from vello_common.

Copy-pasted from vello_common.

@waywardmonkeys waywardmonkeys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is an interesting one ...

In anyrender, it transports the transform along with it:

pub struct BoxShadowCommand {
    pub transform: Affine,
    pub rect: Rect,
    pub brush: Color,
    pub radius: f64,
    pub std_dev: f64,
}

In imaging, it does as well and includes a composite:

/// A solid-color rounded rectangle blurred with a gaussian filter.
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct BlurredRoundedRect {
    /// Geometry transform.
    pub transform: Affine,
    /// Unblurred rectangle bounds.
    pub rect: Rect,
    /// Solid color used by the blurred rectangle.
    pub color: peniko::Color,
    /// Uniform corner radius in user-space units.
    pub radius: f64,
    /// Gaussian standard deviation in user-space units.
    pub std_dev: f64,
    /// Per-draw compositing.
    pub composite: Composite,
}

Obviously, we could use this to store the 4 fields as a single shared structure definition, but that wouldn't necessarily make the API better / different.

Not sure.

@xorgy

xorgy commented Jun 8, 2026

Copy link
Copy Markdown
Member

@waywardmonkeys I could see that being useful/convenient for serializing or for lowering into renderers without the specialization (likely a straight copy, rather than a manual swizzle). In that sense it would be ‘better’ in at least that way.

@PoignardAzur

Copy link
Copy Markdown
Contributor Author

I think vello_common's version makes the most sense for peniko.

  • First, it's easier to compose than to un-compose, and peniko's items should lean towards composition. It's better to have importers pack a lean BlurredRoundedRectangle in a tuple with other fields, that to have them pack an extended type and ignore some of the fields.
  • Second, this is coherent with other peniko types. peniko::Gradient doesn't include a transform or a blend mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants