Skip to content

Legacy SVG import drops gradient stop-opacity, and a golden example truncates it #96

Description

@softmarshmallow

Found by review during #94, both pre-existing. Filed rather than folded into a rendering rung, since the second one moves committed goldens.

Both became fixable in #94: cg::GradientStop.color is now CGColor32F, which carries a stop's alpha as a float independently of its RGB bytes. Neither is fixed there.

1. crates/grida/src/import/svg/from_usvg.rs

IntoCg<GradientStop> for usvg::Stop builds the stop colour from value.color().into_cg() — always fully opaque — and discards value.opacity(). It carries a [MODEL_MISMATCH] marker for exactly this.

A translucent stop-opacity on an SVG gradient imported through the legacy path renders fully opaque. The widened leaf can now hold it via CGColor32F::from_rgb8_alpha(rgb, value.opacity().get()).

2. crates/grida/examples/golden_sk_svg_filters/main.rs

Builds stop colours with (stop.opacity().get() * 255.0) as u8 — a truncation, not a rounding, so 0.5 becomes 127/255 rather than 128/255, and any float opacity loses precision before the widening. The same from_rgb8_alpha route applies.

This one regenerates goldens, so it needs its own ledgered diff.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions