pub struct Clipper<S: ClipperState = NoSubjects, P: PointScaler = Centi> { /* private fields */ }Expand description
The Clipper struct used as a builder for applying boolean operations to paths.
Implementations§
Source§impl<P: PointScaler> Clipper<NoSubjects, P>
impl<P: PointScaler> Clipper<NoSubjects, P>
Sourcepub fn new() -> Clipper<NoSubjects, P>
pub fn new() -> Clipper<NoSubjects, P>
Creates a new empty Clipper instance.
Source§impl<P: PointScaler> Clipper<NoSubjects, P>
impl<P: PointScaler> Clipper<NoSubjects, P>
Sourcepub fn add_subject(
self,
subject: impl Into<Paths<P>>,
) -> Clipper<WithSubjects, P>
pub fn add_subject( self, subject: impl Into<Paths<P>>, ) -> Clipper<WithSubjects, P>
Adds a subject path to the Clipper instance.
§Examples
use clipper2::*;
let path: Paths = vec![(0.2, 0.2), (6.0, 0.2), (6.0, 6.0), (0.2, 6.0)].into();
let clipper = Clipper::new().add_subject(path);Sourcepub fn add_open_subject(
self,
subject: impl Into<Paths<P>>,
) -> Clipper<WithSubjects, P>
pub fn add_open_subject( self, subject: impl Into<Paths<P>>, ) -> Clipper<WithSubjects, P>
Adds an open subject path to the Clipper instance.
§Examples
use clipper2::*;
let path: Paths = vec![(0.2, 0.2), (6.0, 0.2), (6.0, 6.0), (0.2, 6.0)].into();
let clipper = Clipper::new().add_open_subject(path);Source§impl<P: PointScaler> Clipper<WithSubjects, P>
impl<P: PointScaler> Clipper<WithSubjects, P>
Sourcepub fn add_subject(self, subject: impl Into<Paths<P>>) -> Self
pub fn add_subject(self, subject: impl Into<Paths<P>>) -> Self
Adds another subject path to the Clipper instance.
§Examples
use clipper2::*;
let path: Paths = vec![(0.2, 0.2), (6.0, 0.2), (6.0, 6.0), (0.2, 6.0)].into();
let path2: Paths = vec![(1.2, 1.2), (4.0, 1.2), (1.2, 4.0)].into();
let clipper = Clipper::new().add_subject(path).add_subject(path2);Sourcepub fn add_open_subject(self, subject: impl Into<Paths<P>>) -> Self
pub fn add_open_subject(self, subject: impl Into<Paths<P>>) -> Self
Adds another open subject path to the Clipper instance.
§Examples
use clipper2::*;
let path: Paths = vec![(0.2, 0.2), (6.0, 0.2), (6.0, 6.0), (0.2, 6.0)].into();
let path2: Paths = vec![(1.2, 1.2), (4.0, 1.2), (1.2, 4.0)].into();
let clipper = Clipper::new().add_subject(path).add_open_subject(path2);Sourcepub fn add_clip(self, clip: impl Into<Paths<P>>) -> Clipper<WithClips, P>
pub fn add_clip(self, clip: impl Into<Paths<P>>) -> Clipper<WithClips, P>
Adds a clip path to the Clipper instance.
§Examples
use clipper2::*;
let path: Paths = vec![(0.2, 0.2), (6.0, 0.2), (6.0, 6.0), (0.2, 6.0)].into();
let path2: Paths = vec![(1.2, 1.2), (4.0, 1.2), (1.2, 4.0)].into();
let clipper = Clipper::new().add_subject(path).add_clip(path2);Source§impl<P: PointScaler> Clipper<WithClips, P>
impl<P: PointScaler> Clipper<WithClips, P>
Sourcepub fn add_clip(self, clip: impl Into<Paths<P>>) -> Self
pub fn add_clip(self, clip: impl Into<Paths<P>>) -> Self
Adds another clip path to the Clipper instance.
§Examples
use clipper2::*;
let path: Paths = vec![(0.2, 0.2), (6.0, 0.2), (6.0, 6.0), (0.2, 6.0)].into();
let path2: Paths = vec![(1.2, 1.2), (4.0, 1.2), (1.2, 4.0)].into();
let path3: Paths = vec![(2.2, 2.2), (5.0, 2.2), (2.2, 5.0)].into();
let clipper = Clipper::new().add_subject(path).add_clip(path2).add_clip(path3);Sourcepub fn union(self, fill_rule: FillRule) -> Result<Paths<P>, ClipperError>
pub fn union(self, fill_rule: FillRule) -> Result<Paths<P>, ClipperError>
Applies a union boolean operation to the Clipper instance.
§Examples
use clipper2::*;
let path: Paths = vec![(0.2, 0.2), (6.0, 0.2), (6.0, 6.0), (0.2, 6.0)].into();
let path2: Paths = vec![(1.2, 1.2), (4.0, 1.2), (1.2, 4.0)].into();
let result = Clipper::new().add_subject(path).add_clip(path2).union(FillRule::NonZero);For more details see the original union docs.
Sourcepub fn difference(self, fill_rule: FillRule) -> Result<Paths<P>, ClipperError>
pub fn difference(self, fill_rule: FillRule) -> Result<Paths<P>, ClipperError>
Applies a difference boolean operation to the Clipper instance.
§Examples
use clipper2::*;
let path: Paths = vec![(0.2, 0.2), (6.0, 0.2), (6.0, 6.0), (0.2, 6.0)].into();
let path2: Paths = vec![(1.2, 1.2), (4.0, 1.2), (1.2, 4.0)].into();
let result = Clipper::new().add_subject(path).add_clip(path2).difference(FillRule::NonZero);For more details see the original difference docs.
Sourcepub fn intersect(self, fill_rule: FillRule) -> Result<Paths<P>, ClipperError>
pub fn intersect(self, fill_rule: FillRule) -> Result<Paths<P>, ClipperError>
Applies an intersection boolean operation to the Clipper instance.
§Examples
use clipper2::*;
let path: Paths = vec![(0.2, 0.2), (6.0, 0.2), (6.0, 6.0), (0.2, 6.0)].into();
let path2: Paths = vec![(1.2, 1.2), (4.0, 1.2), (1.2, 4.0)].into();
let result = Clipper::new().add_subject(path).add_clip(path2).intersect(FillRule::NonZero);For more details see the original intersect docs.
Sourcepub fn xor(self, fill_rule: FillRule) -> Result<Paths<P>, ClipperError>
pub fn xor(self, fill_rule: FillRule) -> Result<Paths<P>, ClipperError>
Applies an xor boolean operation to the Clipper instance.
§Examples
use clipper2::*;
let path: Paths = vec![(0.2, 0.2), (6.0, 0.2), (6.0, 6.0), (0.2, 6.0)].into();
let path2: Paths = vec![(1.2, 1.2), (4.0, 1.2), (1.2, 4.0)].into();
let result = Clipper::new().add_subject(path).add_clip(path2).xor(FillRule::NonZero);For more details see the original xor docs.