Fix #995: a width-profile stroke keeps its shape when the view zooms out

The canvas keeps a hairline visible by raising a stroke's weight to half a device pixel. A width profile multiplies that weight, so a 1 pt stroke with a 6x width point swelled to twice its size at 25% zoom and shrank back on zooming in. The minimum now goes to the profile's widest point instead; plain strokes are unchanged.
This commit is contained in:
Taha-Mahmoodi
2026-10-31 19:43:16 +07:00
committed by bflatastic
parent 59eb658fd7
commit f65d28378f
5 changed files with 81 additions and 3 deletions
+5 -2
View File
@@ -109,8 +109,11 @@ impl Renderer {
}
ctx.set_transform(f.view * xf);
let closed = effects::stroke::is_closed(bp);
// Keep hairlines visible when zoomed far out (at least ~1 device pixel).
let width = effects::stroke::aligned_width(st, closed).max(f.px * 0.5 / xf.determinant().abs().sqrt().max(1e-9));
// Keep hairlines visible when zoomed far out (at least ~1 device pixel). A width profile
// multiplies the weight, so it is the profile's widest point that is kept visible: raising
// the weight further would swell the whole stroke while the view zooms out (#995).
let widest = st.profile.as_ref().map_or(1.0, |p| p.widest().max(1e-3));
let width = effects::stroke::aligned_width(st, closed).max(f.px * 0.5 / xf.determinant().abs().sqrt().max(1e-9) / widest);
let inside = st.align == StrokeAlign::Inside && closed;
if inside {
ctx.set_fill_rule(fill_rule(rule));