mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-21 18:04:03 +01:00
EPS import: shfill in its own method (graphics_op under the complexity limit)
This commit is contained in:
1 parent
046d4e67ff
commit
1d689ac4d7
1 file changed
+35
-31
@@ -519,39 +519,43 @@ impl Interp<'_> {
|
||||
}
|
||||
self.stroke_path(bp)?;
|
||||
}
|
||||
ShFill => {
|
||||
let d = self.pop_dict()?;
|
||||
if self.g.null {
|
||||
return Ok(());
|
||||
}
|
||||
if is_mesh(&d) {
|
||||
let m = self.xf();
|
||||
return self.mesh_fill(&d, m);
|
||||
}
|
||||
let m = self.xf();
|
||||
if let Some(g) = self.gradient(&d, m)? {
|
||||
let area = self.clip_bounds()?;
|
||||
// Not extended, it paints only between its ends.
|
||||
let extent = shading_extent(&d, m, area);
|
||||
let path = match &extent {
|
||||
Some(pts) if pts.len() < 3 => return Ok(()),
|
||||
Some(pts) => polygon(pts),
|
||||
None => area.to_path(0.1),
|
||||
};
|
||||
let paint = Paint::Gradient(Box::new(g));
|
||||
let clips = self.g.clips.clone();
|
||||
self.out.fill(path, FillRule::NonZero, paint, self.g.overprint, &clips);
|
||||
// Only a fill of the whole clip can stand in for the clip's shape.
|
||||
if extent.is_none()
|
||||
&& let Some((_, n)) = self.out.drawn.last()
|
||||
{
|
||||
let id = n.id;
|
||||
self.out.shadings.insert(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
ShFill => self.shfill()?,
|
||||
_ => self.data_op(op)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `shfill`: shading `sh` over the clip, as a gradient mesh or a gradient fill.
|
||||
fn shfill(&mut self) -> Res {
|
||||
let d = self.pop_dict()?;
|
||||
if self.g.null {
|
||||
return Ok(());
|
||||
}
|
||||
if is_mesh(&d) {
|
||||
let m = self.xf();
|
||||
return self.mesh_fill(&d, m);
|
||||
}
|
||||
let m = self.xf();
|
||||
if let Some(g) = self.gradient(&d, m)? {
|
||||
let area = self.clip_bounds()?;
|
||||
// Not extended, it paints only between its ends.
|
||||
let extent = shading_extent(&d, m, area);
|
||||
let path = match &extent {
|
||||
Some(pts) if pts.len() < 3 => return Ok(()),
|
||||
Some(pts) => polygon(pts),
|
||||
None => area.to_path(0.1),
|
||||
};
|
||||
let paint = Paint::Gradient(Box::new(g));
|
||||
let clips = self.g.clips.clone();
|
||||
self.out.fill(path, FillRule::NonZero, paint, self.g.overprint, &clips);
|
||||
// Only a fill of the whole clip can stand in for the clip's shape.
|
||||
if extent.is_none()
|
||||
&& let Some((_, n)) = self.out.drawn.last()
|
||||
{
|
||||
let id = n.id;
|
||||
self.out.shadings.insert(id);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user