mirror of
https://github.com/penpot/penpot.git
synced 2026-09-11 06:28:47 +00:00
Merge pull request #8545 from penpot/superalex-fix-non-uniform-stroke-scaling-path-shapes-wasm
🐛 Fix non-uniform stroke scaling on path shapes in WASM renderer
This commit is contained in:
commit
6c20bfbc9b
@ -164,16 +164,25 @@ fn draw_stroke_on_path(
|
|||||||
blur: Option<&ImageFilter>,
|
blur: Option<&ImageFilter>,
|
||||||
antialias: bool,
|
antialias: bool,
|
||||||
) {
|
) {
|
||||||
let skia_path = path
|
|
||||||
.to_skia_path()
|
|
||||||
.make_transform(path_transform.unwrap_or(&Matrix::default()));
|
|
||||||
|
|
||||||
let is_open = path.is_open();
|
let is_open = path.is_open();
|
||||||
|
|
||||||
let mut draw_paint = paint.clone();
|
let mut draw_paint = paint.clone();
|
||||||
let filter = compose_filters(blur, shadow);
|
let filter = compose_filters(blur, shadow);
|
||||||
draw_paint.set_image_filter(filter);
|
draw_paint.set_image_filter(filter);
|
||||||
|
|
||||||
|
// Move path_transform from the path geometry to the canvas so the
|
||||||
|
// stroke width is not distorted by non-uniform shape scaling.
|
||||||
|
// The path coordinates are already in world space, so we draw the
|
||||||
|
// raw path on a canvas where the shape transform has been undone:
|
||||||
|
// canvas * path_transform = View × parents (no shape scale/rotation)
|
||||||
|
// This matches the SVG renderer, which bakes the transform into path
|
||||||
|
// coordinates and never sets a transform attribute on the element.
|
||||||
|
let save_count = canvas.save();
|
||||||
|
if let Some(pt) = path_transform {
|
||||||
|
canvas.concat(pt);
|
||||||
|
}
|
||||||
|
let skia_path = path.to_skia_path();
|
||||||
|
|
||||||
match stroke.render_kind(is_open) {
|
match stroke.render_kind(is_open) {
|
||||||
StrokeKind::Inner => {
|
StrokeKind::Inner => {
|
||||||
draw_inner_stroke_path(canvas, &skia_path, &draw_paint, blur, antialias);
|
draw_inner_stroke_path(canvas, &skia_path, &draw_paint, blur, antialias);
|
||||||
@ -187,6 +196,8 @@ fn draw_stroke_on_path(
|
|||||||
}
|
}
|
||||||
|
|
||||||
handle_stroke_caps(&skia_path, stroke, canvas, is_open, paint, blur, antialias);
|
handle_stroke_caps(&skia_path, stroke, canvas, is_open, paint, blur, antialias);
|
||||||
|
|
||||||
|
canvas.restore_to_count(save_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_stroke_cap(
|
fn handle_stroke_cap(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user