diagrams-boolean-0.1.0: boolean operations on Diagrams paths

Safe HaskellNone
LanguageHaskell98

Diagrams.TwoD.Boolean

Contents

Description

Set operations on paths. As a side effect it removes overlapping regions. Since Path is TrailLike, you can use these operations directly on most diagrams combinators which generate Loops, like circle or fromSegments. Lines are discarded, only Loops are used. If you have several paths, you can combine them first with <>. Use toPath if you want to convert a Trail or `Located Trail` to a Path. The FillRule argument determines how insideness is calculated.

Synopsis

operations on Paths

union :: FillRule -> Path V2 Double -> Path V2 Double Source #

Remove overlapping regions in the path. If you have several paths, combine them using <> first.

example = strokePath $ union Winding $
          (square 1) <> circle 0.5 # translate (V2 0.5 (-0.5))

difference :: FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double Source #

Difference of two paths. First overlap is removed in the two input arguments, then the difference is calculated.

example = strokePath $
         difference Winding (square 1) $
         circle 0.5 # translate (V2 0.5 (-0.5))

intersection :: FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double Source #

Intersection of two paths. First overlap is removed in the two input arguments, then the intersection is calculated.

example = strokePath $
         intersection Winding (square 1) $
         circle 0.5 # translate (V2 0.5 (-0.5))

exclusion :: FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double Source #

Exclusion (exclusive or) of two paths. First overlap is removed in the two input arguments, then the exclusion is calculated.

example = fc grey $ strokePath $
          exclusion Winding (square 1) $
          circle 0.5 # translate (V2 0.5 (-0.5))

operations on Paths with tolerance

union' :: Double -> FillRule -> Path V2 Double -> Path V2 Double Source #

Like union, but takes a tolerance parameter.

difference' :: Double -> FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double Source #

Like difference, but takes a tolerance parameter.

intersection' :: Double -> FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double Source #

Like intersection, but takes a tolerance parameter.

exclusion' :: Double -> FillRule -> Path V2 Double -> Path V2 Double -> Path V2 Double Source #

Like exclusion, but takes a tolerance parameter.

operations on Loops

loopUnion :: Double -> FillRule -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)] Source #

Union of a list of loops.

loopDifference :: Double -> FillRule -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)] Source #

Difference between loops. The loops in both lists are first merged using union.

loopIntersection :: Double -> FillRule -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)] Source #

Intersection of loops. The loops in both lists are first merged using union.

loopExclusion :: Double -> FillRule -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)] -> [Located (Trail' Loop V2 Double)] Source #

Exclusion (xor) of loops. The loops in both lists are first merged using union.