wumpus-drawing-0.3.0: High-level drawing objects built on Wumpus-Basic.

PortabilityGHC
Stabilityhighly unstable
MaintainerStephen Tetley <stephen.tetley@gmail.com>

Wumpus.Drawing.Paths.Base.AbsPath

Contents

Description

Absolute path type - this should be more amenable for building complex drawings than the PrimPath type in Wumpus-Core.

Synopsis

Absolute path type

data AbsPath u Source

Absolute path data type.

Instances

Functor AbsPath 
(Ord u, Tolerance u) => Eq (AbsPath u) 
Show u => Show (AbsPath u) 

Construction

empty :: Floating u => Point2 u -> AbsPath uSource

Create the empty path.

Note - an absolute path needs locating and cannot be built without a start point. Figuratively, the empty path is a path from the start point to the start point.

Thus AbsPath operates as a semigroup but not a monoid.

line1 :: Floating u => Point2 u -> Point2 u -> AbsPath uSource

Create an absolute path as a straight line between the supplied points.

curve1 :: (Floating u, Ord u, Tolerance u) => Point2 u -> Point2 u -> Point2 u -> Point2 u -> AbsPath uSource

Create an absolute path from a single cubic Bezier curve.

vertexPath :: (Floating u, Ord u, Tolerance u) => [Point2 u] -> AbsPath uSource

vertexPath throws a runtime error if the supplied list is empty.

curvePath :: (Floating u, Ord u, Tolerance u) => [Point2 u] -> AbsPath uSource

curvePath consumes 4 points from the list on the intial step (start, control1, control2, end) then steps through the list taking 3 points at a time thereafter (control1,control2, end). Leftover points are discarded.

curvePath throws a runtime error if the supplied list is has less than 4 elements (start, control1, control2, end).

controlCurve :: (Floating u, Ord u, Tolerance u) => Point2 u -> Radian -> Radian -> Point2 u -> AbsPath uSource

This is not an arc...

Queries

null :: AbsPath u -> BoolSource

Is the path empty?

length :: Num u => AbsPath u -> uSource

Length of the Path.

Length is the length of the path as it is drawn, it is not a count of the number or path segments.

Length is cached so this operation is cheap - though this put a tax on the build operations.

Concat and extension

append :: (Floating u, Ord u, Tolerance u) => AbsPath u -> AbsPath u -> AbsPath uSource

Append two AbsPaths.

If the end of the first path and the start of the second path coalesce then the paths are joined directly, otherwise, a straight line segment is added to join the paths.

Neither path is moved. Consider RelPath if you need different concatenation.

consLineTo :: Floating u => Point2 u -> AbsPath u -> AbsPath uSource

Prefix the path with a straight line segment from the supplied point.

snocLineTo :: Floating u => AbsPath u -> Point2 u -> AbsPath uSource

Suffix the path with a straight line segment to the supplied point.

consCurveTo :: (Floating u, Ord u, Tolerance u) => Point2 u -> Point2 u -> Point2 u -> AbsPath u -> AbsPath uSource

Prefix the path with a Bezier curve segment formed by the supplied points.

snocCurveTo :: (Floating u, Ord u, Tolerance u) => AbsPath u -> Point2 u -> Point2 u -> Point2 u -> AbsPath uSource

Suffix the path with a Bezier curve segment formed by the supplied points.

pathconcat :: (Floating u, Ord u, Tolerance u) => AbsPath u -> [AbsPath u] -> AbsPath uSource

Concat the list of paths onto the intial path.

Because a true empty path cannot be constructed (i.e. the empty path needs a start point even if it has no segments) - the list is in destructor form. Client code has to decide how to handle the empty list case, e.g.:

 case paths of
  (x:xs) -> Just $ pathconcat x xs
  []     -> Nothing

Conversion

toPrimPath :: InterpretUnit u => AbsPath u -> Query PrimPathSource

Turn a Path into an ordinary PrimPath.

Assumes path is properly formed - i.e. end point of one segment is the same point as the start point of the next segment.

Shortening

shortenPath :: (Real u, Floating u) => u -> u -> AbsPath u -> AbsPath uSource

sortenPath : left_dist * right_dist * path -> Path

shortenL :: (Real u, Floating u) => u -> AbsPath u -> AbsPath uSource

Note - shortening a line from the left by greater-than-or-equal its length is operationally equivalent to making a zero-length line at the end point.

shortenR :: (Real u, Floating u) => u -> AbsPath u -> AbsPath uSource

Note - shortening a line from the right by greater-than-or-equal its length is operationally equivalent to making a zero-length line at the start point.

Tips and direction

directionL :: (Real u, Floating u) => AbsPath u -> RadianSource

Direction of empty path is considered to be 0.

directionR :: (Real u, Floating u) => AbsPath u -> RadianSource

Direction of empty path is considered to be 0.

Path anchors

atend :: (Real u, Floating u) => AbsPath u -> (Point2 u, Radian)Source

Views

data PathViewL u Source

Constructors

PathOneL (PathSegment u) 
(PathSegment u) :<< (AbsPath u) 

Instances

data PathViewR u Source

Constructors

PathOneR (PathSegment u) 
(AbsPath u) :>> (PathSegment u) 

Instances

data PathSegment u Source

Constructors

LineSeg (Point2 u) (Point2 u) 
CurveSeg (Point2 u) (Point2 u) (Point2 u) (Point2 u) 

Instances

roundTrail :: (Real u, Floating u, Tolerance u) => u -> [Point2 u] -> AbsPath uSource

roundTrail : rounding_distance * [point] -> Path

Build a path from the list of vertices, all the interior corners are rounded by the rounding distance *and* final round corner is created "incorporating" the start point (as the start point becomes a rounded corner the actual path will not intersect it).

It is expected that this function will be used to create round cornered shapes.

roundTrail throws a runtime error if the input list is empty. If the list has one element the null path is built, if the list has two elements a straight line is built.

roundInterior :: (Real u, Floating u, Tolerance u) => u -> [Point2 u] -> AbsPath uSource

roundInterior : rounding_distance * [point] -> Path

Build a path from the list of vertices, all the interior corners are rounded by the rounding distance. Unlike roundTrail there is no loop around to the start point, and start path will begin exactly on the start point and end exactly on the end point.

roundInterior throws a runtime error if the input list is empty. If the list has one element the null path is built, if the list has two elements a straight line is built.