Maintainer | diagrams-discuss@googlegroups.com |
---|
Paths in two dimensions are special since we may stroke them to create a 2D diagram, and (eventually) perform operations such as intersection and union.
- stroke :: Renderable (Path R2) b => Path R2 -> Diagram b R2
- stroke' :: (Renderable (Path R2) b, IsName a) => StrokeOpts a -> Path R2 -> Diagram b R2
- strokeT :: Renderable (Path R2) b => Trail R2 -> Diagram b R2
- strokeT' :: (Renderable (Path R2) b, IsName a) => StrokeOpts a -> Trail R2 -> Diagram b R2
- data FillRule
- newtype FillRuleA = FillRuleA (Last FillRule)
- getFillRule :: FillRuleA -> FillRule
- fillRule :: HasStyle a => FillRule -> a -> a
- data StrokeOpts a = StrokeOpts {
- vertexNames :: [[a]]
- queryFillRule :: FillRule
- isInsideWinding :: P2 -> Path R2 -> Bool
- isInsideEvenOdd :: P2 -> Path R2 -> Bool
- newtype Clip = Clip {}
- clipBy :: (HasStyle a, V a ~ R2) => Path R2 -> a -> a
Constructing path-based diagrams
stroke :: Renderable (Path R2) b => Path R2 -> Diagram b R2Source
Convert a path into a diagram. The resulting diagram has the names 0, 1, ... assigned to each of the path's vertices.
See also stroke'
, which takes an extra options record allowing
its behavior to be customized.
Note that a bug in GHC 7.0.1 causes a context stack overflow when
inferring the type of stroke
. The solution is to give a type
signature to expressions involving stroke
, or (recommended)
upgrade GHC (the bug is fixed in 7.0.2 onwards).
stroke' :: (Renderable (Path R2) b, IsName a) => StrokeOpts a -> Path R2 -> Diagram b R2Source
A variant of stroke
that takes an extra record of options to
customize its behavior. In particular:
- Names can be assigned to the path's vertices
StrokeOpts
is an instance of Default
, so stroke'
syntax may be used.
with
{
... }
strokeT :: Renderable (Path R2) b => Trail R2 -> Diagram b R2Source
A composition of stroke
and pathFromTrail
for conveniently
converting a trail directly into a diagram.
Note that a bug in GHC 7.0.1 causes a context stack overflow when
inferring the type of stroke
and hence of strokeT
as well.
The solution is to give a type signature to expressions involving
strokeT
, or (recommended) upgrade GHC (the bug is fixed in 7.0.2
onwards).
strokeT' :: (Renderable (Path R2) b, IsName a) => StrokeOpts a -> Trail R2 -> Diagram b R2Source
A composition of stroke'
and pathFromTrail
for conveniently
converting a trail directly into a diagram.
Stroke options
Enumeration of algorithms or "rules" for determining which points lie in the interior of a (possibly self-intersecting) closed path.
Winding | Interior points are those with a nonzero winding number. See http://en.wikipedia.org/wiki/Nonzero-rule. |
EvenOdd | Interior points are those where a ray extended infinitely in a particular direction crosses the path an odd number of times. See http://en.wikipedia.org/wiki/Even-odd_rule. |
getFillRule :: FillRuleA -> FillRuleSource
Extract the fill rule from a FillRuleA
attribute.
fillRule :: HasStyle a => FillRule -> a -> aSource
Specify the fill rule that should be used for determining which points are inside a path.
data StrokeOpts a Source
A record of options that control how a path is stroked.
StrokeOpts
is an instance of Default
, so a StrokeOpts
records can be created using
notation.
with
{ ... }
StrokeOpts | |
|
Default (StrokeOpts a) |
Inside/outside testing
isInsideWinding :: P2 -> Path R2 -> BoolSource
Test whether the given point is inside the given (closed) path,
by testing whether the point's winding number is nonzero. Note
that False
is always returned for open paths, regardless of
the winding number.
isInsideEvenOdd :: P2 -> Path R2 -> BoolSource
Test whether the given point is inside the given (closed) path,
by testing whether a ray extending from the point in the positive
x direction crosses the path an even (outside) or odd (inside)
number of times. Note that False
is always returned for
open paths, regardless of the number of crossings.
Clipping
Clip
tracks the accumulated clipping paths applied to a
diagram. Note that the semigroup structure on Clip
is list
concatenation, so applying multiple clipping paths is sensible.
The clipping region is the intersection of all the applied
clipping paths.