diagrams-contrib-1.4.4: Collection of user contributions to diagrams EDSL

Diagrams.TwoD.Path.Boolean

Description

Set operations on paths. As a side effect it removes overlapping regions. Since Path is TrailLike, you can use these operations directly with any combinator which generates Trail's, like circle or fromSegments. Trail's are discarded, only Trail's are used. If you have several paths, you can combine them with <> first. Use toPath if you want to convert a Trail or Located Trail to a Path. The FillRule argument determines how insideness is calculated for the input.

Synopsis

# Operations on Paths

Remove overlapping regions in the path. If you have several paths, combine them using <> first. import Diagrams.TwoD.Path.Boolean
import Diagrams.Prelude hiding (union)

unionEx = frame 0.1 . strokePath $union Winding$
(square 1) <> circle 0.5 # translate (V2 0.5 (-0.5))

Difference of two paths. First overlap is removed in the two input arguments, then the difference is calculated. import Diagrams.TwoD.Path.Boolean
import Diagrams.Prelude hiding (difference)

diffEx = frame 0.1 . strokePath $difference Winding (square 1)$
circle 0.5 # translate (V2 0.5 (-0.5))

Intersection of two paths. First overlap is removed in the two input arguments, then the intersection is calculated. import Diagrams.TwoD.Path.Boolean
import Diagrams.Prelude hiding (intersection)

isectEx = frame 0.1 . strokePath $intersection Winding (square 1)$
circle 0.5 # translate (V2 0.5 (-0.5))

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

exclEx = fc grey . frame 0.1 . strokePath $exclusion Winding (square 1)$
circle 0.5 # translate (V2 0.5 (-0.5))

# Operations on Paths with tolerance

Like union, but takes a tolerance parameter.

Like difference, but takes a tolerance parameter.

Like intersection, but takes a tolerance parameter.

Like exclusion, but takes a tolerance parameter.

# Operations on Loops

Union of a list of loops.

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

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

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