mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-30 10:16:46 +01:00
M3: fill_with without the mask no caller passes, and without lint allows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012eBDgsvRwsSRpWeWrzabVY
This commit is contained in:
1 parent
071fe03776
commit
0a6d3220bb
1 file changed
+7
-20
@@ -183,19 +183,7 @@ fn averaged_when_shrunk(prep: Prepared, path: &tiny_skia::Path, xf: Affine, limi
|
||||
/// coloured backdrop, a plus-lighter or luminosity fill over a translucent one, come out the
|
||||
/// same with or without effects on the shape); a pass-through frame's paints blend with the
|
||||
/// backdrop too.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn fill_with(
|
||||
pix: &mut Pixmap,
|
||||
path: &tiny_skia::Path,
|
||||
paints: &[Paint],
|
||||
w: f64,
|
||||
h: f64,
|
||||
xf: Affine,
|
||||
rule: FillRule,
|
||||
ctx: &Ctx,
|
||||
mask: Option<&Mask>,
|
||||
isolate: bool,
|
||||
) {
|
||||
fn fill_with(pix: &mut Pixmap, path: &tiny_skia::Path, paints: &[Paint], w: f64, h: f64, xf: Affine, rule: FillRule, ctx: &Ctx, isolate: bool) {
|
||||
let blended = |p: &Paint| p.visible && p.opacity > 0.0 && !matches!(p.blend, BlendMode::Normal | BlendMode::PassThrough);
|
||||
if isolate && paints.iter().any(blended) {
|
||||
let area = path
|
||||
@@ -210,15 +198,14 @@ fn fill_with(
|
||||
let at = Affine::translate((-f64::from(r.x()), -f64::from(r.y()))) * xf;
|
||||
paint_each(&mut alone, path, paints, w, h, at, rule, ctx, None);
|
||||
let pp = PixmapPaint::default();
|
||||
pix.draw_pixmap(r.x(), r.y(), alone.as_ref(), &pp, Transform::identity(), mask);
|
||||
pix.draw_pixmap(r.x(), r.y(), alone.as_ref(), &pp, Transform::identity(), None);
|
||||
return;
|
||||
}
|
||||
}
|
||||
paint_each(pix, path, paints, w, h, xf, rule, ctx, mask);
|
||||
paint_each(pix, path, paints, w, h, xf, rule, ctx, None);
|
||||
}
|
||||
|
||||
/// Paint `paints` over `path` onto `pix`, each by its own blend mode.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn paint_each(
|
||||
pix: &mut Pixmap,
|
||||
path: &tiny_skia::Path,
|
||||
@@ -1191,7 +1178,7 @@ fn fill_vector_regions(ctx: &Ctx, pix: &mut Pixmap, n: &Node, network: &figcraft
|
||||
path.apply_affine(frame.inverse());
|
||||
let Some(tp) = ts_path(&path) else { continue };
|
||||
let rule = if region.winding == figcraft_doc::WindingRule::EvenOdd { FillRule::EvenOdd } else { FillRule::Winding };
|
||||
fill_with(pix, &tp, paints, pw, ph, xf * frame, rule, ctx, None, isolates_paints(n));
|
||||
fill_with(pix, &tp, paints, pw, ph, xf * frame, rule, ctx, isolates_paints(n));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1202,7 +1189,7 @@ fn fill_outline(ctx: &Ctx, pix: &mut Pixmap, n: &Node, paints: &[Paint], path: &
|
||||
let under = fill_to_stroke_middle(n, path, rule);
|
||||
let (path, rule) = under.as_ref().map_or((path, rule), |(p, r)| (&**p, *r));
|
||||
if let Some(tp) = ts_path(path) {
|
||||
fill_with(pix, &tp, paints, n.width, n.height, xf, rule, ctx, None, isolates_paints(n));
|
||||
fill_with(pix, &tp, paints, n.width, n.height, xf, rule, ctx, isolates_paints(n));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1277,7 +1264,7 @@ fn draw_content(ctx: &Ctx, pix: &mut Pixmap, n: &Node, xf: Affine, depth: usize,
|
||||
for path in keys.iter().filter_map(|k| by_style.get(k)) {
|
||||
let s = stroke_area(n, path, true);
|
||||
if let Some(ts) = ts_path(&s) {
|
||||
fill_with(pix, &ts, &n.strokes, w, h, gxf, stroke_rule(n, true), ctx, None, isolates_paints(n));
|
||||
fill_with(pix, &ts, &n.strokes, w, h, gxf, stroke_rule(n, true), ctx, isolates_paints(n));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1316,7 +1303,7 @@ fn draw_content(ctx: &Ctx, pix: &mut Pixmap, n: &Node, xf: Affine, depth: usize,
|
||||
if let Some(g) = geom {
|
||||
let area = stroke_area(n, &g, closed);
|
||||
if let Some(tp) = ts_path(&area) {
|
||||
fill_with(pix, &tp, &n.strokes, w, h, xf, stroke_rule(n, closed), ctx, None, isolates_paints(n));
|
||||
fill_with(pix, &tp, &n.strokes, w, h, xf, stroke_rule(n, closed), ctx, isolates_paints(n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user