fix(hatch): render weighted pattern strokes

Show styled boundaries only while selected.\n\nRefs #821
This commit is contained in:
Hakan Seven committed 2026-08-25 22:44:51 +03:00
1 parent 81de94fdbb
commit fd801fac1b
6 files changed
+55 -23

No files matched your search

+7 -5
View File
@@ -151,7 +151,6 @@ fn check_family(
let pz = xz.y - oz;
let perp_step = fam.perp_step * scale;
let line_w = abs(fam.line_width * scale);
let perp = -px * sin_a + pz * cos_a;
let k = round(perp / perp_step);
@@ -163,6 +162,8 @@ fn check_family(
-ddx_xz.x * sin_a + ddx_xz.y * cos_a,
-ddy_xz.x * sin_a + ddy_xz.y * cos_a,
)) * 0.5;
let width_px = select(1.0, max(fam.line_width, 1.0), u.lwdisplay_enable > 0.5);
let half_line = half_px * width_px;
// World units per screen pixel on each axis — used to light exactly the
// one pixel that contains a dot's centre (pixel-snapped, so the dot stays
@@ -172,8 +173,8 @@ fn check_family(
// A fragment within ~1px of a line may be a dot; everything further out is
// empty fill. (A dot's pixel sits on a line, so its perp offset is < 1px.)
if d > half_px * 2.0 { return false; }
if fam.n_dashes == 0u { return d <= half_px; }
if d > max(half_line, half_px * 2.0) { return false; }
if fam.n_dashes == 0u { return d <= half_line; }
let along_step = fam.along_step * scale;
let period = fam.period * scale;
@@ -185,7 +186,7 @@ fn check_family(
for (var j = 0u; j < fam.n_dashes; j++) {
let sv = dashes[fam.dash_offset + j] * scale;
if sv > 0.0 {
if d <= half_px && t_mod >= pos && t_mod < pos + sv { return true; }
if d <= half_line && t_mod >= pos && t_mod < pos + sv { return true; }
pos = pos + sv;
} else if sv < 0.0 {
pos = pos - sv;
@@ -197,7 +198,8 @@ fn check_family(
let dtv = (t - pos) - round((t - pos) / period) * period;
let owx = -dtv * cos_a + dperp * sin_a;
let owy = -dtv * sin_a - dperp * cos_a;
if abs(owx / wpx) <= 0.5 && abs(owy / wpy) <= 0.5 { return true; }
let dot_half = width_px * 0.5;
if abs(owx / wpx) <= dot_half && abs(owy / wpy) <= dot_half { return true; }
}
}
return false;
+7 -4
View File
@@ -146,13 +146,15 @@ fn check_family(
-ddx_xz.x * sin_a + ddx_xz.y * cos_a,
-ddy_xz.x * sin_a + ddy_xz.y * cos_a,
)) * 0.5;
let width_px = select(1.0, max(fam.line_width, 1.0), u.lwdisplay_enable > 0.5);
let half_line = half_px * width_px;
let wpx = length(vec2<f32>(ddx_xz.x, ddy_xz.x));
let wpy = length(vec2<f32>(ddx_xz.y, ddy_xz.y));
if d > half_px * 2.0 { return false; }
if d > max(half_line, half_px * 2.0) { return false; }
if fam.n_dashes == 0u { return d <= half_px; }
if fam.n_dashes == 0u { return d <= half_line; }
let along_step = fam.along_step * scale;
let period = fam.period * scale;
@@ -165,7 +167,7 @@ fn check_family(
let idx = fam.dash_off + j;
let sv = texel(h.dash_off + idx / 4u)[idx % 4u] * scale;
if sv > 0.0 {
if d <= half_px && t_mod >= pos && t_mod < pos + sv { return true; }
if d <= half_line && t_mod >= pos && t_mod < pos + sv { return true; }
pos = pos + sv;
} else if sv < 0.0 {
pos = pos - sv;
@@ -173,7 +175,8 @@ fn check_family(
let dtv = (t - pos) - round((t - pos) / period) * period;
let owx = -dtv * cos_a + dperp * sin_a;
let owy = -dtv * sin_a - dperp * cos_a;
if abs(owx / wpx) <= 0.5 && abs(owy / wpy) <= 0.5 { return true; }
let dot_half = width_px * 0.5;
if abs(owx / wpx) <= dot_half && abs(owy / wpy) <= dot_half { return true; }
}
}
return false;