diagrams-lib-1.5.1: Embedded domain-specific language for declarative graphics

Copyright | (c) 2011-2013 diagrams-lib team (see LICENSE)
License | BSD-style (see LICENSE)
Maintainer | diagrams-discuss@googlegroups.com
Safe Haskell | None
Language | Haskell2010

Diagrams.Segment

Contents

- Open/closed tags
- Segment offsets
- Constructing and modifying segments
- Fixed (absolutely located) segments
- Segment measures

Description

A segment is a translation-invariant, atomic path. Currently, there are two types: linear (i.e. just a straight line to the endpoint) and cubic Bézier curves (i.e. a curve to an endpoint with two control points). This module contains tools for creating and manipulating segments, as well as a definition of segments with a fixed location (useful for backend implementors).

Generally speaking, casual users of diagrams should not need this module; the higher-level functionality provided by Diagrams.Trail, Diagrams.TrailLike, and Diagrams.Path should usually suffice. However, directly manipulating segments can occasionally be useful.

Synopsis

- data Open
- data Closed
- data Offset c (v :: Type -> Type) n where
  - OffsetOpen :: forall (v :: Type -> Type) n. Offset Open v n
  - OffsetClosed :: forall (v :: Type -> Type) n. v n -> Offset Closed v n
- segOffset :: Segment Closed v n -> v n
- data Segment c (v :: Type -> Type) n
  - = Linear !(Offset c v n)
  - | Cubic !(v n) !(v n) !(Offset c v n)
- straight :: v n -> Segment Closed v n
- bezier3 :: v n -> v n -> v n -> Segment Closed v n
- bézier3 :: v n -> v n -> v n -> Segment Closed v n
- reverseSegment :: forall n (v :: Type -> Type). (Num n, Additive v) => Segment Closed v n -> Segment Closed v n
- mapSegmentVectors :: (v n -> v' n') -> Segment c v n -> Segment c v' n'
- openLinear :: forall (v :: Type -> Type) n. Segment Open v n
- openCubic :: v n -> v n -> Segment Open v n
- data FixedSegment (v :: Type -> Type) n
  - = FLinear (Point v n) (Point v n)
  - | FCubic (Point v n) (Point v n) (Point v n) (Point v n)
- mkFixedSeg :: forall n (v :: Type -> Type). (Num n, Additive v) => Located (Segment Closed v n) -> FixedSegment v n
- fromFixedSeg :: forall n (v :: Type -> Type). (Num n, Additive v) => FixedSegment v n -> Located (Segment Closed v n)
- fixedSegIso :: forall n (v :: Type -> Type). (Num n, Additive v) => Iso' (FixedSegment v n) (Located (Segment Closed v n))
- newtype SegCount = SegCount (Sum Int)
- newtype ArcLength n = ArcLength (Sum (Interval n), n -> Sum (Interval n))
- getArcLengthCached :: ArcLength n -> Interval n
- getArcLengthFun :: ArcLength n -> n -> Interval n
- getArcLengthBounded :: (Num n, Ord n) => n -> ArcLength n -> Interval n
- newtype TotalOffset (v :: Type -> Type) n = TotalOffset (v n)
- data OffsetEnvelope (v :: Type -> Type) n = OffsetEnvelope {
  - _oeOffset :: !(TotalOffset v n)
  - _oeEnvelope :: Envelope v n
  }
- oeOffset :: forall (v :: Type -> Type) n f. Functor f => (TotalOffset v n -> f (TotalOffset v n)) -> OffsetEnvelope v n -> f (OffsetEnvelope v n)
- oeEnvelope :: forall (v :: Type -> Type) n f. Functor f => (Envelope v n -> f (Envelope v n)) -> OffsetEnvelope v n -> f (OffsetEnvelope v n)
- type SegMeasure (v :: Type -> Type) n = SegCount ::: (ArcLength n ::: (OffsetEnvelope v n ::: ()))

# Open/closed tags

data Open Source #

Type tag for open segments.

#### Instances

Instances details

Serialize (v n) => Serialize (Segment Open v n) Source # |
Instance details Defined in Diagrams.Segment Methods put :: Putter (Segment Open v n) Source # get :: Get (Segment Open v n) Source #

data Closed Source #

Type tag for closed segments.

#### Instances

Instances details

(Additive v, Num n) => EndValues (Tangent (Segment Closed v n)) Source # |
Instance details Defined in Diagrams.Tangent Methods atStart :: Tangent (Segment Closed v n) -> Codomain (Tangent (Segment Closed v n)) (N (Tangent (Segment Closed v n))) Source # atEnd :: Tangent (Segment Closed v n) -> Codomain (Tangent (Segment Closed v n)) (N (Tangent (Segment Closed v n))) Source #
(Additive v, Num n) => Parametric (Tangent (Segment Closed v n)) Source # |
Instance details Defined in Diagrams.Tangent Methods atParam :: Tangent (Segment Closed v n) -> N (Tangent (Segment Closed v n)) -> Codomain (Tangent (Segment Closed v n)) (N (Tangent (Segment Closed v n))) Source #
ToPath (Located (Segment Closed v n)) Source # |
Instance details Defined in Diagrams.Path Methods toPath :: Located (Segment Closed v n) -> Path (V (Located (Segment Closed v n))) (N (Located (Segment Closed v n))) Source #
ToPath (Located [Segment Closed v n]) Source # |
Instance details Defined in Diagrams.Path Methods toPath :: Located [Segment Closed v n] -> Path (V (Located [Segment Closed v n])) (N (Located [Segment Closed v n])) Source #
(Metric v, OrderedField n, Metric u, OrderedField n') => Cons (SegTree v n) (SegTree u n') (Segment Closed v n) (Segment Closed u n') Source # |
Instance details Defined in Diagrams.Trail Methods _Cons :: Prism (SegTree v n) (SegTree u n') (Segment Closed v n, SegTree v n) (Segment Closed u n', SegTree u n') Source #
(Metric v, OrderedField n, Metric u, OrderedField n') => Snoc (SegTree v n) (SegTree u n') (Segment Closed v n) (Segment Closed u n') Source # |
Instance details Defined in Diagrams.Trail Methods _Snoc :: Prism (SegTree v n) (SegTree u n') (SegTree v n, Segment Closed v n) (SegTree u n', Segment Closed u n') Source #
(OrderedField n, Metric v) => Measured (SegMeasure v n) (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods measure :: Segment Closed v n -> SegMeasure v n Source #
Serialize (v n) => Serialize (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods put :: Putter (Segment Closed v n) Source # get :: Get (Segment Closed v n) Source #
(Metric v, OrderedField n) => Enveloped (Segment Closed v n) Source # | The envelope for a segment is based at the segment's start.
Instance details Defined in Diagrams.Segment Methods getEnvelope :: Segment Closed v n -> Envelope (V (Segment Closed v n)) (N (Segment Closed v n)) Source #
OrderedField n => Traced (Segment Closed V2 n) Source # |
Instance details Defined in Diagrams.TwoD.Segment Methods getTrace :: Segment Closed V2 n -> Trace (V (Segment Closed V2 n)) (N (Segment Closed V2 n)) Source #
Num n => DomainBounds (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods domainLower :: Segment Closed v n -> N (Segment Closed v n) Source # domainUpper :: Segment Closed v n -> N (Segment Closed v n) Source #
(Additive v, Num n) => EndValues (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods atStart :: Segment Closed v n -> Codomain (Segment Closed v n) (N (Segment Closed v n)) Source # atEnd :: Segment Closed v n -> Codomain (Segment Closed v n) (N (Segment Closed v n)) Source #
(Metric v, OrderedField n) => HasArcLength (Segment Closed v n) Source # |

Instance details

Defined in Diagrams.Segment

Methods

arcLengthBounded :: N (Segment Closed v n) -> Segment Closed v n -> Interval (N (Segment Closed v n)) Source #

arcLength :: N (Segment Closed v n) -> Segment Closed v n -> N (Segment Closed v n) Source #

stdArcLength :: Segment Closed v n -> N (Segment Closed v n) Source #

arcLengthToParam :: N (Segment Closed v n) -> Segment Closed v n -> N (Segment Closed v n) -> N (Segment Closed v n) Source #

stdArcLengthToParam :: Segment Closed v n -> N (Segment Closed v n) -> N (Segment Closed v n) Source #

(Additive v, Num n) => Parametric (Segment Closed v n) Source # | `atParam` yields a parametrized view of segments as continuous functions `[0,1] -> v`, which give the offset from the start of the segment for each value of the parameter between `0` and `1`. It is designed to be used infix, like `seg ``atParam`` 0.5`.
Instance details Defined in Diagrams.Segment Methods atParam :: Segment Closed v n -> N (Segment Closed v n) -> Codomain (Segment Closed v n) (N (Segment Closed v n)) Source #
(Additive v, Fractional n) => Sectionable (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods splitAtParam :: Segment Closed v n -> N (Segment Closed v n) -> (Segment Closed v n, Segment Closed v n) Source # section :: Segment Closed v n -> N (Segment Closed v n) -> N (Segment Closed v n) -> Segment Closed v n Source # reverseDomain :: Segment Closed v n -> Segment Closed v n Source #
(Additive v, Num n) => Reversing (Segment Closed v n) Source # | Reverse the direction of a segment.
Instance details Defined in Diagrams.Segment Methods reversing :: Segment Closed v n -> Segment Closed v n Source #
(Metric v, OrderedField n, Metric u, OrderedField n') => Cons (Trail' Line v n) (Trail' Line u n') (Segment Closed v n) (Segment Closed u n') Source # |
Instance details Defined in Diagrams.Trail Methods _Cons :: Prism (Trail' Line v n) (Trail' Line u n') (Segment Closed v n, Trail' Line v n) (Segment Closed u n', Trail' Line u n') Source #
(Metric v, OrderedField n, Metric u, OrderedField n') => Snoc (Trail' Line v n) (Trail' Line u n') (Segment Closed v n) (Segment Closed u n') Source # |
Instance details Defined in Diagrams.Trail Methods _Snoc :: Prism (Trail' Line v n) (Trail' Line u n') (Trail' Line v n, Segment Closed v n) (Trail' Line u n', Segment Closed u n') Source #
type Codomain (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment type Codomain (Segment Closed v n) = v

# Segment offsets

data Offset c (v :: Type -> Type) n where Source #

The offset of a segment is the vector from its starting point to its end. The offset for an open segment is determined by the context, i.e. its endpoint is not fixed. The offset for a closed segment is stored explicitly, i.e. its endpoint is at a fixed offset from its start.

Constructors

OffsetOpen :: forall (v :: Type -> Type) n. Offset Open v n |
OffsetClosed :: forall (v :: Type -> Type) n. v n -> Offset Closed v n |

#### Instances

Instances details

Functor v => Functor (Offset c v) Source # |
Instance details Defined in Diagrams.Segment Methods fmap :: (a -> b) -> Offset c v a -> Offset c v b Source # (<$) :: a -> Offset c v b -> Offset c v a Source #
Transformable (Offset c v n) Source # |
Instance details Defined in Diagrams.Segment Methods transform :: Transformation (V (Offset c v n)) (N (Offset c v n)) -> Offset c v n -> Offset c v n Source #
Show (v n) => Show (Offset c v n) Source # |
Instance details Defined in Diagrams.Segment Methods showsPrec :: Int -> Offset c v n -> ShowS Source # show :: Offset c v n -> String Source # showList :: [Offset c v n] -> ShowS Source #
Eq (v n) => Eq (Offset c v n) Source # |
Instance details Defined in Diagrams.Segment Methods (==) :: Offset c v n -> Offset c v n -> Bool Source # (/=) :: Offset c v n -> Offset c v n -> Bool Source #
Ord (v n) => Ord (Offset c v n) Source # |

Instance details

Defined in Diagrams.Segment

Methods

compare :: Offset c v n -> Offset c v n -> Ordering Source #

(<) :: Offset c v n -> Offset c v n -> Bool Source #

(<=) :: Offset c v n -> Offset c v n -> Bool Source #

(>) :: Offset c v n -> Offset c v n -> Bool Source #

(>=) :: Offset c v n -> Offset c v n -> Bool Source #

max :: Offset c v n -> Offset c v n -> Offset c v n Source #

min :: Offset c v n -> Offset c v n -> Offset c v n Source #

(Additive v, Num n) => Reversing (Offset c v n) Source # | Reverses the direction of closed offsets.
Instance details Defined in Diagrams.Segment Methods reversing :: Offset c v n -> Offset c v n Source #
r ~ Offset c u n => AffineMappable (Offset c v n) r Source # |
Instance details Defined in Diagrams.LinearMap Methods amap :: AffineMap (V (Offset c v n)) (V r) (N r) -> Offset c v n -> r Source #
r ~ Offset c u m => LinearMappable (Offset c v n) r Source # |
Instance details Defined in Diagrams.LinearMap Methods vmap :: (Vn (Offset c v n) -> Vn r) -> Offset c v n -> r Source #
Each (Offset c v n) (Offset c v' n') (v n) (v' n') Source # |
Instance details Defined in Diagrams.Segment Methods each :: Traversal (Offset c v n) (Offset c v' n') (v n) (v' n') Source #
type N (Offset c v n) Source # |
Instance details Defined in Diagrams.Segment type N (Offset c v n) = n
type V (Offset c v n) Source # |
Instance details Defined in Diagrams.Segment type V (Offset c v n) = v

segOffset :: Segment Closed v n -> v n Source #

Compute the offset from the start of a segment to the end. Note that in the case of a Bézier segment this is not the same as the length of the curve itself; for that, see `arcLength`.

# Constructing and modifying segments

data Segment c (v :: Type -> Type) n Source #

The atomic constituents of the concrete representation currently used for trails are segments, currently limited to single straight lines or cubic Bézier curves. Segments are translationally invariant, that is, they have no particular "location" and are unaffected by translations. They are, however, affected by other transformations such as rotations and scales.

Constructors

Linear !(Offset c v n) | A linear segment with given offset.
Cubic !(v n) !(v n) !(Offset c v n) | A cubic Bézier segment specified by three offsets from the starting point to the first control point, second control point, and ending point, respectively.

#### Instances

Instances details

(Additive v, Num n) => EndValues (Tangent (Segment Closed v n)) Source # |
Instance details Defined in Diagrams.Tangent Methods atStart :: Tangent (Segment Closed v n) -> Codomain (Tangent (Segment Closed v n)) (N (Tangent (Segment Closed v n))) Source # atEnd :: Tangent (Segment Closed v n) -> Codomain (Tangent (Segment Closed v n)) (N (Tangent (Segment Closed v n))) Source #
(Additive v, Num n) => Parametric (Tangent (Segment Closed v n)) Source # |
Instance details Defined in Diagrams.Tangent Methods atParam :: Tangent (Segment Closed v n) -> N (Tangent (Segment Closed v n)) -> Codomain (Tangent (Segment Closed v n)) (N (Tangent (Segment Closed v n))) Source #
ToPath (Located (Segment Closed v n)) Source # |
Instance details Defined in Diagrams.Path Methods toPath :: Located (Segment Closed v n) -> Path (V (Located (Segment Closed v n))) (N (Located (Segment Closed v n))) Source #
ToPath (Located [Segment Closed v n]) Source # |
Instance details Defined in Diagrams.Path Methods toPath :: Located [Segment Closed v n] -> Path (V (Located [Segment Closed v n])) (N (Located [Segment Closed v n])) Source #
Functor v => Functor (Segment c v) Source # |
Instance details Defined in Diagrams.Segment Methods fmap :: (a -> b) -> Segment c v a -> Segment c v b Source # (<$) :: a -> Segment c v b -> Segment c v a Source #
(Metric v, OrderedField n, Metric u, OrderedField n') => Cons (SegTree v n) (SegTree u n') (Segment Closed v n) (Segment Closed u n') Source # |
Instance details Defined in Diagrams.Trail Methods _Cons :: Prism (SegTree v n) (SegTree u n') (Segment Closed v n, SegTree v n) (Segment Closed u n', SegTree u n') Source #
(Metric v, OrderedField n, Metric u, OrderedField n') => Snoc (SegTree v n) (SegTree u n') (Segment Closed v n) (Segment Closed u n') Source # |
Instance details Defined in Diagrams.Trail Methods _Snoc :: Prism (SegTree v n) (SegTree u n') (SegTree v n, Segment Closed v n) (SegTree u n', Segment Closed u n') Source #
(OrderedField n, Metric v) => Measured (SegMeasure v n) (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods measure :: Segment Closed v n -> SegMeasure v n Source #
Serialize (v n) => Serialize (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods put :: Putter (Segment Closed v n) Source # get :: Get (Segment Closed v n) Source #
Serialize (v n) => Serialize (Segment Open v n) Source # |
Instance details Defined in Diagrams.Segment Methods put :: Putter (Segment Open v n) Source # get :: Get (Segment Open v n) Source #
(Metric v, OrderedField n) => Enveloped (Segment Closed v n) Source # | The envelope for a segment is based at the segment's start.
Instance details Defined in Diagrams.Segment Methods getEnvelope :: Segment Closed v n -> Envelope (V (Segment Closed v n)) (N (Segment Closed v n)) Source #
OrderedField n => Traced (Segment Closed V2 n) Source # |
Instance details Defined in Diagrams.TwoD.Segment Methods getTrace :: Segment Closed V2 n -> Trace (V (Segment Closed V2 n)) (N (Segment Closed V2 n)) Source #
Transformable (Segment c v n) Source # |
Instance details Defined in Diagrams.Segment Methods transform :: Transformation (V (Segment c v n)) (N (Segment c v n)) -> Segment c v n -> Segment c v n Source #
Num n => DomainBounds (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods domainLower :: Segment Closed v n -> N (Segment Closed v n) Source # domainUpper :: Segment Closed v n -> N (Segment Closed v n) Source #
(Additive v, Num n) => EndValues (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods atStart :: Segment Closed v n -> Codomain (Segment Closed v n) (N (Segment Closed v n)) Source # atEnd :: Segment Closed v n -> Codomain (Segment Closed v n) (N (Segment Closed v n)) Source #
(Metric v, OrderedField n) => HasArcLength (Segment Closed v n) Source # |

Instance details

Defined in Diagrams.Segment

Methods

arcLengthBounded :: N (Segment Closed v n) -> Segment Closed v n -> Interval (N (Segment Closed v n)) Source #

arcLength :: N (Segment Closed v n) -> Segment Closed v n -> N (Segment Closed v n) Source #

stdArcLength :: Segment Closed v n -> N (Segment Closed v n) Source #

arcLengthToParam :: N (Segment Closed v n) -> Segment Closed v n -> N (Segment Closed v n) -> N (Segment Closed v n) Source #

stdArcLengthToParam :: Segment Closed v n -> N (Segment Closed v n) -> N (Segment Closed v n) Source #

(Additive v, Num n) => Parametric (Segment Closed v n) Source # | `atParam` yields a parametrized view of segments as continuous functions `[0,1] -> v`, which give the offset from the start of the segment for each value of the parameter between `0` and `1`. It is designed to be used infix, like `seg ``atParam`` 0.5`.
Instance details Defined in Diagrams.Segment Methods atParam :: Segment Closed v n -> N (Segment Closed v n) -> Codomain (Segment Closed v n) (N (Segment Closed v n)) Source #
(Additive v, Fractional n) => Sectionable (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods splitAtParam :: Segment Closed v n -> N (Segment Closed v n) -> (Segment Closed v n, Segment Closed v n) Source # section :: Segment Closed v n -> N (Segment Closed v n) -> N (Segment Closed v n) -> Segment Closed v n Source # reverseDomain :: Segment Closed v n -> Segment Closed v n Source #
Show (v n) => Show (Segment c v n) Source # |
Instance details Defined in Diagrams.Segment Methods showsPrec :: Int -> Segment c v n -> ShowS Source # show :: Segment c v n -> String Source # showList :: [Segment c v n] -> ShowS Source #
Eq (v n) => Eq (Segment c v n) Source # |
Instance details Defined in Diagrams.Segment Methods (==) :: Segment c v n -> Segment c v n -> Bool Source # (/=) :: Segment c v n -> Segment c v n -> Bool Source #
Ord (v n) => Ord (Segment c v n) Source # |

Instance details

Defined in Diagrams.Segment

Methods

compare :: Segment c v n -> Segment c v n -> Ordering Source #

(<) :: Segment c v n -> Segment c v n -> Bool Source #

(<=) :: Segment c v n -> Segment c v n -> Bool Source #

(>) :: Segment c v n -> Segment c v n -> Bool Source #

(>=) :: Segment c v n -> Segment c v n -> Bool Source #

max :: Segment c v n -> Segment c v n -> Segment c v n Source #

min :: Segment c v n -> Segment c v n -> Segment c v n Source #

(Additive v, Num n) => Reversing (Segment Closed v n) Source # | Reverse the direction of a segment.
Instance details Defined in Diagrams.Segment Methods reversing :: Segment Closed v n -> Segment Closed v n Source #
Renderable (Segment c v n) NullBackend Source # |
Instance details Defined in Diagrams.Segment Methods render :: NullBackend -> Segment c v n -> Render NullBackend (V (Segment c v n)) (N (Segment c v n)) Source #
r ~ Segment c u n => AffineMappable (Segment c v n) r Source # |
Instance details Defined in Diagrams.LinearMap Methods amap :: AffineMap (V (Segment c v n)) (V r) (N r) -> Segment c v n -> r Source #
r ~ Segment c u m => LinearMappable (Segment c v n) r Source # |
Instance details Defined in Diagrams.LinearMap Methods vmap :: (Vn (Segment c v n) -> Vn r) -> Segment c v n -> r Source #
Each (Segment c v n) (Segment c v' n') (v n) (v' n') Source # |
Instance details Defined in Diagrams.Segment Methods each :: Traversal (Segment c v n) (Segment c v' n') (v n) (v' n') Source #
(Metric v, OrderedField n, Metric u, OrderedField n') => Cons (Trail' Line v n) (Trail' Line u n') (Segment Closed v n) (Segment Closed u n') Source # |
Instance details Defined in Diagrams.Trail Methods _Cons :: Prism (Trail' Line v n) (Trail' Line u n') (Segment Closed v n, Trail' Line v n) (Segment Closed u n', Trail' Line u n') Source #
(Metric v, OrderedField n, Metric u, OrderedField n') => Snoc (Trail' Line v n) (Trail' Line u n') (Segment Closed v n) (Segment Closed u n') Source # |
Instance details Defined in Diagrams.Trail Methods _Snoc :: Prism (Trail' Line v n) (Trail' Line u n') (Trail' Line v n, Segment Closed v n) (Trail' Line u n', Segment Closed u n') Source #
type N (Segment c v n) Source # |
Instance details Defined in Diagrams.Segment type N (Segment c v n) = n
type V (Segment c v n) Source # |
Instance details Defined in Diagrams.Segment type V (Segment c v n) = v
type Codomain (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment type Codomain (Segment Closed v n) = v

straight :: v n -> Segment Closed v n Source #

``straight` v` constructs a translationally invariant linear segment with direction and length given by the vector `v`.

bezier3 :: v n -> v n -> v n -> Segment Closed v n Source #

`bezier3 c1 c2 x` constructs a translationally invariant cubic Bézier curve where the offsets from the first endpoint to the first and second control point and endpoint are respectively given by `c1`, `c2`, and `x`.

bézier3 :: v n -> v n -> v n -> Segment Closed v n Source #

`bézier3` is the same as `bezier3`, but with more snobbery.

reverseSegment :: forall n (v :: Type -> Type). (Num n, Additive v) => Segment Closed v n -> Segment Closed v n Source #

Reverse the direction of a segment.

mapSegmentVectors :: (v n -> v' n') -> Segment c v n -> Segment c v' n' Source #

Map over the vectors of each segment.

openLinear :: forall (v :: Type -> Type) n. Segment Open v n Source #

An open linear segment. This means the trail makes a straight line from the last segment the beginning to form a loop.

openCubic :: v n -> v n -> Segment Open v n Source #

An open cubic segment. This means the trail makes a cubic bézier with control vectors `v1` and `v2` to form a loop.

# Fixed (absolutely located) segments

data FixedSegment (v :: Type -> Type) n Source #

`FixedSegment`s are like `Segment`s except that they have absolute locations. `FixedSegment v` is isomorphic to `Located (Segment Closed v)`, as witnessed by `mkFixedSeg` and `fromFixedSeg`, but `FixedSegment` is convenient when one needs the absolute locations of the vertices and control points.

Constructors

FLinear (Point v n) (Point v n) |
FCubic (Point v n) (Point v n) (Point v n) (Point v n) |

#### Instances

Instances details

(Additive v, Num n) => EndValues (Tangent (FixedSegment v n)) Source # |
Instance details Defined in Diagrams.Tangent Methods atStart :: Tangent (FixedSegment v n) -> Codomain (Tangent (FixedSegment v n)) (N (Tangent (FixedSegment v n))) Source # atEnd :: Tangent (FixedSegment v n) -> Codomain (Tangent (FixedSegment v n)) (N (Tangent (FixedSegment v n))) Source #
(Additive v, Num n) => Parametric (Tangent (FixedSegment v n)) Source # |
Instance details Defined in Diagrams.Tangent Methods atParam :: Tangent (FixedSegment v n) -> N (Tangent (FixedSegment v n)) -> Codomain (Tangent (FixedSegment v n)) (N (Tangent (FixedSegment v n))) Source #
(Metric v, OrderedField n) => Enveloped (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment Methods getEnvelope :: FixedSegment v n -> Envelope (V (FixedSegment v n)) (N (FixedSegment v n)) Source #
(Additive v, Num n) => HasOrigin (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment Methods moveOriginTo :: Point (V (FixedSegment v n)) (N (FixedSegment v n)) -> FixedSegment v n -> FixedSegment v n Source #
OrderedField n => Traced (FixedSegment V2 n) Source # |
Instance details Defined in Diagrams.TwoD.Segment Methods getTrace :: FixedSegment V2 n -> Trace (V (FixedSegment V2 n)) (N (FixedSegment V2 n)) Source #
(Additive v, Num n) => Transformable (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment Methods transform :: Transformation (V (FixedSegment v n)) (N (FixedSegment v n)) -> FixedSegment v n -> FixedSegment v n Source #
Num n => DomainBounds (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment Methods domainLower :: FixedSegment v n -> N (FixedSegment v n) Source # domainUpper :: FixedSegment v n -> N (FixedSegment v n) Source #
(Additive v, Num n) => EndValues (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment Methods atStart :: FixedSegment v n -> Codomain (FixedSegment v n) (N (FixedSegment v n)) Source # atEnd :: FixedSegment v n -> Codomain (FixedSegment v n) (N (FixedSegment v n)) Source #
(Metric v, OrderedField n) => HasArcLength (FixedSegment v n) Source # |

Instance details

Defined in Diagrams.Segment

Methods

arcLengthBounded :: N (FixedSegment v n) -> FixedSegment v n -> Interval (N (FixedSegment v n)) Source #

arcLength :: N (FixedSegment v n) -> FixedSegment v n -> N (FixedSegment v n) Source #

stdArcLength :: FixedSegment v n -> N (FixedSegment v n) Source #

arcLengthToParam :: N (FixedSegment v n) -> FixedSegment v n -> N (FixedSegment v n) -> N (FixedSegment v n) Source #

stdArcLengthToParam :: FixedSegment v n -> N (FixedSegment v n) -> N (FixedSegment v n) Source #

(Additive v, Num n) => Parametric (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment Methods atParam :: FixedSegment v n -> N (FixedSegment v n) -> Codomain (FixedSegment v n) (N (FixedSegment v n)) Source #
(Additive v, Fractional n) => Sectionable (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment Methods splitAtParam :: FixedSegment v n -> N (FixedSegment v n) -> (FixedSegment v n, FixedSegment v n) Source # section :: FixedSegment v n -> N (FixedSegment v n) -> N (FixedSegment v n) -> FixedSegment v n Source # reverseDomain :: FixedSegment v n -> FixedSegment v n Source #
ToPath (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Path Methods toPath :: FixedSegment v n -> Path (V (FixedSegment v n)) (N (FixedSegment v n)) Source #
Show (v n) => Show (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment Methods showsPrec :: Int -> FixedSegment v n -> ShowS Source # show :: FixedSegment v n -> String Source # showList :: [FixedSegment v n] -> ShowS Source #
Eq (v n) => Eq (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment Methods (==) :: FixedSegment v n -> FixedSegment v n -> Bool Source # (/=) :: FixedSegment v n -> FixedSegment v n -> Bool Source #
Ord (v n) => Ord (FixedSegment v n) Source # |

Instance details

Defined in Diagrams.Segment

Methods

compare :: FixedSegment v n -> FixedSegment v n -> Ordering Source #

(<) :: FixedSegment v n -> FixedSegment v n -> Bool Source #

(<=) :: FixedSegment v n -> FixedSegment v n -> Bool Source #

(>) :: FixedSegment v n -> FixedSegment v n -> Bool Source #

(>=) :: FixedSegment v n -> FixedSegment v n -> Bool Source #

max :: FixedSegment v n -> FixedSegment v n -> FixedSegment v n Source #

min :: FixedSegment v n -> FixedSegment v n -> FixedSegment v n Source #

Reversing (FixedSegment v n) Source # | Reverses the control points.
Instance details Defined in Diagrams.Segment Methods reversing :: FixedSegment v n -> FixedSegment v n Source #
r ~ FixedSegment u n => AffineMappable (FixedSegment v n) r Source # |
Instance details Defined in Diagrams.LinearMap Methods amap :: AffineMap (V (FixedSegment v n)) (V r) (N r) -> FixedSegment v n -> r Source #
r ~ FixedSegment u m => LinearMappable (FixedSegment v n) r Source # |
Instance details Defined in Diagrams.LinearMap Methods vmap :: (Vn (FixedSegment v n) -> Vn r) -> FixedSegment v n -> r Source #
Each (FixedSegment v n) (FixedSegment v' n') (Point v n) (Point v' n') Source # |
Instance details Defined in Diagrams.Segment Methods each :: Traversal (FixedSegment v n) (FixedSegment v' n') (Point v n) (Point v' n') Source #
type N (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment type N (FixedSegment v n) = n
type V (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment type V (FixedSegment v n) = v
type Codomain (FixedSegment v n) Source # |
Instance details Defined in Diagrams.Segment type Codomain (FixedSegment v n) = Point v

mkFixedSeg :: forall n (v :: Type -> Type). (Num n, Additive v) => Located (Segment Closed v n) -> FixedSegment v n Source #

Create a `FixedSegment` from a located `Segment`.

fromFixedSeg :: forall n (v :: Type -> Type). (Num n, Additive v) => FixedSegment v n -> Located (Segment Closed v n) Source #

Convert a `FixedSegment` back into a located `Segment`.

fixedSegIso :: forall n (v :: Type -> Type). (Num n, Additive v) => Iso' (FixedSegment v n) (Located (Segment Closed v n)) Source #

Use a `FixedSegment` to make an `Iso` between an a fixed segment and a located segment.

# Segment measures

Trails store a sequence of segments in a fingertree, which can automatically track various monoidal "measures" on segments.

newtype SegCount Source #

A type to track the count of segments in a `Trail`.

Constructors

SegCount (Sum Int) |

#### Instances

Instances details

Monoid SegCount Source # |
Instance details Defined in Diagrams.Segment Methods mempty :: SegCount Source # mappend :: SegCount -> SegCount -> SegCount Source # mconcat :: [SegCount] -> SegCount Source #
Semigroup SegCount Source # |
Instance details Defined in Diagrams.Segment Methods (<>) :: SegCount -> SegCount -> SegCount Source # sconcat :: NonEmpty SegCount -> SegCount Source # stimes :: Integral b => b -> SegCount -> SegCount Source #
Wrapped SegCount Source # |

Instance details

Defined in Diagrams.Segment

Associated Types

type Unwrapped SegCount |
Instance details Defined in Diagrams.Segment type Unwrapped SegCount = Sum Int

Methods

_Wrapped' :: Iso' SegCount (Unwrapped SegCount) Source #

Rewrapped SegCount SegCount Source # |
Instance details Defined in Diagrams.Segment
(Metric v, OrderedField n) => Measured (SegMeasure v n) (SegMeasure v n) Source # |
Instance details Defined in Diagrams.Segment Methods measure :: SegMeasure v n -> SegMeasure v n Source #
(Ord n, Metric v, Floating n) => Measured (SegMeasure v n) (SegTree v n) Source # |
Instance details Defined in Diagrams.Trail Methods measure :: SegTree v n -> SegMeasure v n Source #
(OrderedField n, Metric v) => Measured (SegMeasure v n) (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods measure :: Segment Closed v n -> SegMeasure v n Source #
type Unwrapped SegCount Source # |
Instance details Defined in Diagrams.Segment type Unwrapped SegCount = Sum Int

newtype ArcLength n Source #

A type to represent the total arc length of a chain of segments. The first component is a "standard" arc length, computed to within a tolerance of `10e-6`. The second component is a generic arc length function taking the tolerance as an argument.

Constructors

ArcLength (Sum (Interval n), n -> Sum (Interval n)) |

#### Instances

Instances details

(Num n, Ord n) => Monoid (ArcLength n) Source # |
Instance details Defined in Diagrams.Segment Methods mempty :: ArcLength n Source # mappend :: ArcLength n -> ArcLength n -> ArcLength n Source # mconcat :: [ArcLength n] -> ArcLength n Source #
(Num n, Ord n) => Semigroup (ArcLength n) Source # |
Instance details Defined in Diagrams.Segment Methods (<>) :: ArcLength n -> ArcLength n -> ArcLength n Source # sconcat :: NonEmpty (ArcLength n) -> ArcLength n Source # stimes :: Integral b => b -> ArcLength n -> ArcLength n Source #
Wrapped (ArcLength n) Source # |

Instance details

Defined in Diagrams.Segment

Associated Types

type Unwrapped (ArcLength n) |
Instance details Defined in Diagrams.Segment type Unwrapped (ArcLength n) = (Sum (Interval n), n -> Sum (Interval n))

Methods

_Wrapped' :: Iso' (ArcLength n) (Unwrapped (ArcLength n)) Source #

Rewrapped (ArcLength n) (ArcLength n') Source # |
Instance details Defined in Diagrams.Segment
(Metric v, OrderedField n) => Measured (SegMeasure v n) (SegMeasure v n) Source # |
Instance details Defined in Diagrams.Segment Methods measure :: SegMeasure v n -> SegMeasure v n Source #
(Ord n, Metric v, Floating n) => Measured (SegMeasure v n) (SegTree v n) Source # |
Instance details Defined in Diagrams.Trail Methods measure :: SegTree v n -> SegMeasure v n Source #
(OrderedField n, Metric v) => Measured (SegMeasure v n) (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods measure :: Segment Closed v n -> SegMeasure v n Source #
type Unwrapped (ArcLength n) Source # |
Instance details Defined in Diagrams.Segment type Unwrapped (ArcLength n) = (Sum (Interval n), n -> Sum (Interval n))

getArcLengthCached :: ArcLength n -> Interval n Source #

Project out the cached arc length, stored together with error bounds.

getArcLengthFun :: ArcLength n -> n -> Interval n Source #

Project out the generic arc length function taking the tolerance as an argument.

getArcLengthBounded :: (Num n, Ord n) => n -> ArcLength n -> Interval n Source #

Given a specified tolerance, project out the cached arc length if it is accurate enough; otherwise call the generic arc length function with the given tolerance.

newtype TotalOffset (v :: Type -> Type) n Source #

A type to represent the total cumulative offset of a chain of segments.

Constructors

TotalOffset (v n) |

#### Instances

Instances details

(Num n, Additive v) => Monoid (TotalOffset v n) Source # |
Instance details Defined in Diagrams.Segment Methods mempty :: TotalOffset v n Source # mappend :: TotalOffset v n -> TotalOffset v n -> TotalOffset v n Source # mconcat :: [TotalOffset v n] -> TotalOffset v n Source #
(Num n, Additive v) => Semigroup (TotalOffset v n) Source # |
Instance details Defined in Diagrams.Segment Methods (<>) :: TotalOffset v n -> TotalOffset v n -> TotalOffset v n Source # sconcat :: NonEmpty (TotalOffset v n) -> TotalOffset v n Source # stimes :: Integral b => b -> TotalOffset v n -> TotalOffset v n Source #
Wrapped (TotalOffset v n) Source # |

Instance details

Defined in Diagrams.Segment

Associated Types

type Unwrapped (TotalOffset v n) |
Instance details Defined in Diagrams.Segment type Unwrapped (TotalOffset v n) = v n

Methods

_Wrapped' :: Iso' (TotalOffset v n) (Unwrapped (TotalOffset v n)) Source #

Rewrapped (TotalOffset v n) (TotalOffset v' n') Source # |
Instance details Defined in Diagrams.Segment
type Unwrapped (TotalOffset v n) Source # |
Instance details Defined in Diagrams.Segment type Unwrapped (TotalOffset v n) = v n

data OffsetEnvelope (v :: Type -> Type) n Source #

A type to represent the offset and envelope of a chain of segments. They have to be paired into one data structure, since combining the envelopes of two consecutive chains needs to take the offset of the first into account.

Constructors

OffsetEnvelope |

Fields

- _oeOffset :: !(TotalOffset v n)
- _oeEnvelope :: Envelope v n

#### Instances

Instances details

(Metric v, OrderedField n) => Semigroup (OffsetEnvelope v n) Source # |
Instance details Defined in Diagrams.Segment Methods (<>) :: OffsetEnvelope v n -> OffsetEnvelope v n -> OffsetEnvelope v n Source # sconcat :: NonEmpty (OffsetEnvelope v n) -> OffsetEnvelope v n Source # stimes :: Integral b => b -> OffsetEnvelope v n -> OffsetEnvelope v n Source #
(Metric v, OrderedField n) => Measured (SegMeasure v n) (SegMeasure v n) Source # |
Instance details Defined in Diagrams.Segment Methods measure :: SegMeasure v n -> SegMeasure v n Source #
(Ord n, Metric v, Floating n) => Measured (SegMeasure v n) (SegTree v n) Source # |
Instance details Defined in Diagrams.Trail Methods measure :: SegTree v n -> SegMeasure v n Source #
(OrderedField n, Metric v) => Measured (SegMeasure v n) (Segment Closed v n) Source # |
Instance details Defined in Diagrams.Segment Methods measure :: Segment Closed v n -> SegMeasure v n Source #

oeOffset :: forall (v :: Type -> Type) n f. Functor f => (TotalOffset v n -> f (TotalOffset v n)) -> OffsetEnvelope v n -> f (OffsetEnvelope v n) Source #

oeEnvelope :: forall (v :: Type -> Type) n f. Functor f => (Envelope v n -> f (Envelope v n)) -> OffsetEnvelope v n -> f (OffsetEnvelope v n) Source #

type SegMeasure (v :: Type -> Type) n = SegCount ::: (ArcLength n ::: (OffsetEnvelope v n ::: ())) Source #

`SegMeasure` collects up all the measurements over a chain of segments.