Copyright | (c) 2011-2015 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 :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b) => t -> QDiagram b V2 n Any
- stroke' :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> t -> QDiagram b V2 n Any
- strokePath :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any
- strokeP :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any
- strokePath' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any
- strokeP' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any
- strokeTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any
- strokeT :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any
- strokeTrail' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any
- strokeT' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any
- strokeLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Line V2 n -> QDiagram b V2 n Any
- strokeLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Loop V2 n -> QDiagram b V2 n Any
- strokeLocTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any
- strokeLocT :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any
- strokeLocLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Line V2 n) -> QDiagram b V2 n Any
- strokeLocLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Loop V2 n) -> QDiagram b V2 n Any
- data FillRule
- getFillRule :: FillRule -> FillRule
- fillRule :: HasStyle a => FillRule -> a -> a
- _fillRule :: Lens' (Style V2 n) FillRule
- data StrokeOpts a = StrokeOpts {
- _vertexNames :: [[a]]
- _queryFillRule :: FillRule
- vertexNames :: Lens (StrokeOpts a) (StrokeOpts a') [[a]] [[a']]
- queryFillRule :: Lens' (StrokeOpts a) FillRule
- newtype Crossings = Crossings Int
- isInsideWinding :: HasQuery t Crossings => t -> Point (V t) (N t) -> Bool
- isInsideEvenOdd :: HasQuery t Crossings => t -> Point (V t) (N t) -> Bool
- newtype Clip n = Clip [Path V2 n]
- _Clip :: Iso (Clip n) (Clip n') [Path V2 n] [Path V2 n']
- _clip :: (Typeable n, OrderedField n) => Lens' (Style V2 n) [Path V2 n]
- clipBy :: (HasStyle a, V a ~ V2, N a ~ n, TypeableFloat n) => Path V2 n -> a -> a
- clipTo :: TypeableFloat n => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
- clipped :: TypeableFloat n => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any
- intersectPoints :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => t -> s -> [P2 n]
- intersectPoints' :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => n -> t -> s -> [P2 n]
- intersectPointsP :: OrderedField n => Path V2 n -> Path V2 n -> [P2 n]
- intersectPointsP' :: OrderedField n => n -> Path V2 n -> Path V2 n -> [P2 n]
- intersectPointsT :: OrderedField n => Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]
- intersectPointsT' :: OrderedField n => n -> Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n]
Constructing path-based diagrams
stroke :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b) => t -> QDiagram b V2 n Any Source #
Convert a ToPath
object 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 behaviour to be customized.
stroke
::Path
V2
Double
->Diagram
bstroke
::Located
(Trail
V2
Double
) ->Diagram
bstroke
::Located
(Trail'
Loop
V2
Double
) ->Diagram
bstroke
::Located
(Trail'
Line
V2
Double
) ->Diagram
b
stroke' :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> t -> QDiagram b V2 n Any Source #
A variant of stroke
that takes an extra record of options to
customize its behaviour. In particular:
- Names can be assigned to the path's vertices
StrokeOpts
is an instance of Default
, so stroke' (
syntax may be used.with
&
... )
strokePath :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any Source #
strokePath' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any Source #
strokeP' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any Source #
strokeTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any Source #
strokeT :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any Source #
strokeTrail' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any Source #
A composition of stroke'
and pathFromTrail
for conveniently
converting a trail directly into a diagram.
strokeT' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any Source #
Deprecated synonym for strokeTrail'
.
strokeLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Line V2 n -> QDiagram b V2 n Any Source #
strokeLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Loop V2 n -> QDiagram b V2 n Any Source #
strokeLocTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any Source #
A convenience function for converting a Located Trail
directly
into a diagram; strokeLocTrail = stroke . trailLike
.
strokeLocT :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any Source #
Deprecated synonym for strokeLocTrail
.
strokeLocLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Line V2 n) -> QDiagram b V2 n Any Source #
A convenience function for converting a Located
line directly
into a diagram; strokeLocLine = stroke . trailLike . mapLoc wrapLine
.
strokeLocLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Loop V2 n) -> QDiagram b V2 n Any 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) 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 :: FillRule -> 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) Source # | |
vertexNames :: 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 :: Lens' (StrokeOpts a) FillRule Source #
Inside/outside testing
The sum of signed crossings of a path as we travel in the positive x direction from a given point.
- A point is filled according to the
Winding
fill rule, if the number ofCrossings
is non-zero (seeisInsideWinding
). - A point is filled according to the
EvenOdd
fill rule, if the number ofCrossings
is odd (seeisInsideEvenOdd
).
This is the HasQuery
result for Path
s, Located
Trail
s and
Located
Loops
.
sample
::Path
V2
Double
->Point
V2
Double
->Crossings
sample
::Located
(Trail
V2
Double
) ->Point
V2
Double
->Crossings
sample
::Located
(Trail'
Loop
V2
Double
) ->Point
V2
Double
->Crossings
Note that Line
s have no inside or outside, so don't contribute
crossings
isInsideWinding :: HasQuery t Crossings => t -> Point (V t) (N t) -> Bool Source #
Test whether the given point is inside the given path,
by testing whether the point's winding number is nonzero. Note
that False
is always returned for paths consisting of lines
(as opposed to loops), regardless of the winding number.
isInsideWinding
::Path
V2
Double
->Point
V2
Double
->Bool
isInsideWinding
::Located
(Trail
V2
Double
) ->Point
V2
Double
->Bool
isInsideWinding
::Located
(Trail'
Loop
V2
Double
) ->Point
V2
Double
->Bool
isInsideEvenOdd :: HasQuery t Crossings => t -> Point (V t) (N t) -> Bool Source #
Test whether the given point is inside the given 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
paths consisting of lines (as opposed to loops), regardless of
the number of crossings.
isInsideEvenOdd
::Path
V2
Double
->Point
V2
Double
->Bool
isInsideEvenOdd
::Located
(Trail
V2
Double
) ->Point
V2
Double
->Bool
isInsideEvenOdd
::Located
(Trail'
Loop
V2
Double
) ->Point
V2
Double
->Bool
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.
Semigroup (Clip n) Source # | |
Typeable * n => AttributeClass (Clip n) Source # | |
OrderedField n => Transformable (Clip n) Source # | |
AsEmpty (Clip n) Source # | |
Wrapped (Clip n0) Source # | |
(~) * (Clip n0) t0 => Rewrapped (Clip n1) t0 Source # | |
RealFloat n => HasQuery (Clip n) All Source # | A point inside a clip if the point is in |
type V (Clip n) Source # | |
type N (Clip n) Source # | |
type Unwrapped (Clip n0) Source # | |
_clip :: (Typeable n, OrderedField n) => Lens' (Style V2 n) [Path V2 n] Source #
Lens onto the Clip in a style. An empty list means no clipping.
clipBy :: (HasStyle a, V a ~ V2, N a ~ n, TypeableFloat n) => Path V2 n -> 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 :: TypeableFloat n => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any 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.
clipped :: TypeableFloat n => Path V2 n -> QDiagram b V2 n Any -> QDiagram b V2 n Any Source #
Clip a diagram to the clip path taking the envelope and trace of the clip path.
Intersections
intersectPoints :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => t -> s -> [P2 n] Source #
Find the intersect points of two objects that can be converted to a path.
intersectPoints' :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => n -> t -> s -> [P2 n] Source #
Find the intersect points of two objects that can be converted to a path within the given tolerance.
intersectPointsP :: OrderedField n => Path V2 n -> Path V2 n -> [P2 n] Source #
Compute the intersect points between two paths.
intersectPointsP' :: OrderedField n => n -> Path V2 n -> Path V2 n -> [P2 n] Source #
Compute the intersect points between two paths within given tolerance.
intersectPointsT :: OrderedField n => Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n] Source #
Compute the intersect points between two located trails.
intersectPointsT' :: OrderedField n => n -> Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n] Source #
Compute the intersect points between two located trails within the given tolerance.
Orphan instances
RealFloat n => HasQuery (Located (Trail V2 n)) Crossings Source # | |
RealFloat n => HasQuery (Located (Trail' l V2 n)) Crossings Source # | |
RealFloat n => Traced (Trail V2 n) Source # | |
RealFloat n => Traced (Path V2 n) Source # | |
RealFloat n => HasQuery (Path V2 n) Crossings Source # | |
(TypeableFloat n, Renderable (Path V2 n) b) => TrailLike (QDiagram b V2 n Any) Source # | |