Copyright | (c) 2011 diagrams-lib team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | None |
Language | Haskell2010 |
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. They also have a trace, whereas paths in higher dimensions do not.
- stroke :: Renderable (Path R2) b => Path R2 -> Diagram b R2
- stroke' :: (Renderable (Path R2) b, IsName a) => StrokeOpts a -> Path R2 -> Diagram b R2
- strokeTrail :: Renderable (Path R2) b => Trail R2 -> Diagram b R2
- strokeT :: Renderable (Path R2) b => Trail R2 -> Diagram b R2
- strokeTrail' :: (Renderable (Path R2) b, IsName a) => StrokeOpts a -> Trail R2 -> Diagram b R2
- strokeT' :: (Renderable (Path R2) b, IsName a) => StrokeOpts a -> Trail R2 -> Diagram b R2
- strokeLine :: Renderable (Path R2) b => Trail' Line R2 -> Diagram b R2
- strokeLoop :: Renderable (Path R2) b => Trail' Loop R2 -> Diagram b R2
- strokeLocTrail :: Renderable (Path R2) b => Located (Trail R2) -> Diagram b R2
- strokeLocT :: Renderable (Path R2) b => Located (Trail R2) -> Diagram b R2
- strokeLocLine :: Renderable (Path R2) b => Located (Trail' Line R2) -> Diagram b R2
- strokeLocLoop :: Renderable (Path R2) b => Located (Trail' Loop 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
- vertexNames :: forall a a'. Lens (StrokeOpts a) (StrokeOpts a') [[a]] [[a']]
- queryFillRule :: forall a. Lens' (StrokeOpts a) FillRule
- isInsideWinding :: P2 -> Path R2 -> Bool
- isInsideEvenOdd :: P2 -> Path R2 -> Bool
- newtype Clip = Clip [Path R2]
- clipBy :: (HasStyle a, V a ~ R2) => Path R2 -> a -> a
- clipTo :: Renderable (Path R2) b => Path R2 -> Diagram b R2 -> Diagram b R2
- clipped :: Renderable (Path R2) b => Path R2 -> Diagram b R2 -> Diagram b R2
Constructing path-based diagrams
stroke :: Renderable (Path R2) b => Path R2 -> Diagram b R2 Source
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 R2 Source
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
&
... )
strokeTrail :: Renderable (Path R2) b => Trail R2 -> Diagram b R2 Source
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 strokeTrail
as well.
The solution is to give a type signature to expressions involving
strokeTrail
, or (recommended) upgrade GHC (the bug is fixed in 7.0.2
onwards).
strokeT :: Renderable (Path R2) b => Trail R2 -> Diagram b R2 Source
Deprecated synonym for strokeTrail
.
strokeTrail' :: (Renderable (Path R2) b, IsName a) => StrokeOpts a -> Trail R2 -> Diagram b R2 Source
A composition of stroke'
and pathFromTrail
for conveniently
converting a trail directly into a diagram.
strokeT' :: (Renderable (Path R2) b, IsName a) => StrokeOpts a -> Trail R2 -> Diagram b R2 Source
Deprecated synonym for strokeTrail'
.
strokeLine :: Renderable (Path R2) b => Trail' Line R2 -> Diagram b R2 Source
strokeLoop :: Renderable (Path R2) b => Trail' Loop R2 -> Diagram b R2 Source
strokeLocTrail :: Renderable (Path R2) b => Located (Trail R2) -> Diagram b R2 Source
A convenience function for converting a Located Trail
directly
into a diagram; strokeLocTrail = stroke . trailLike
.
strokeLocT :: Renderable (Path R2) b => Located (Trail R2) -> Diagram b R2 Source
Deprecated synonym for strokeLocTrail
.
strokeLocLine :: Renderable (Path R2) b => Located (Trail' Line R2) -> Diagram b R2 Source
A convenience function for converting a Located
line directly
into a diagram; strokeLocLine = stroke . trailLike . mapLoc wrapLine
.
strokeLocLoop :: Renderable (Path R2) b => Located (Trail' Loop R2) -> Diagram b R2 Source
A convenience function for converting a Located
loop directly
into a diagram; strokeLocLoop = stroke . trailLike . mapLoc wrapLoop
.
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 -> FillRule Source
Extract the fill rule from a FillRuleA
attribute.
fillRule :: HasStyle a => FillRule -> a -> a Source
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) |
vertexNames :: forall a a'. Lens (StrokeOpts a) (StrokeOpts a') [[a]] [[a']] Source
Atomic names that should be assigned to the vertices of the path so that they can be referenced later. If there are not enough names, the extra vertices are not assigned names; if there are too many, the extra names are ignored. Note that this is a list of lists of names, since paths can consist of multiple trails. The first list of names are assigned to the vertices of the first trail, the second list to the second trail, and so on.
The default value is the empty list.
queryFillRule :: forall a. Lens' (StrokeOpts a) FillRule Source
Inside/outside testing
isInsideWinding :: P2 -> Path R2 -> Bool Source
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 -> Bool Source
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.
clipBy :: (HasStyle a, V a ~ R2) => Path R2 -> a -> a Source
Clip a diagram by the given path:
- Only the parts of the diagram which lie in the interior of the path will be drawn.
- The envelope of the diagram is unaffected.
clipTo :: Renderable (Path R2) b => Path R2 -> Diagram b R2 -> Diagram b R2 Source
Clip a diagram to the given path setting its envelope to the pointwise minimum of the envelopes of the diagram and path. The trace consists of those parts of the original diagram's trace which fall within the clipping path, or parts of the path's trace within the original diagram.