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

Copyright(c) 2011-2015 diagrams-lib team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.TwoD

Contents

Description

This module defines the two-dimensional vector space R^2, two-dimensional transformations, and various predefined two-dimensional shapes. This module re-exports useful functionality from a group of more specific modules:

Synopsis

R^2

data V2 a :: * -> * #

A 2-dimensional vector

>>> pure 1 :: V2 Int
V2 1 1
>>> V2 1 2 + V2 3 4
V2 4 6
>>> V2 1 2 * V2 3 4
V2 3 8
>>> sum (V2 1 2)
3

Constructors

V2 ~a ~a 

Instances

Monad V2 

Methods

(>>=) :: V2 a -> (a -> V2 b) -> V2 b #

(>>) :: V2 a -> V2 b -> V2 b #

return :: a -> V2 a #

fail :: String -> V2 a #

Functor V2 

Methods

fmap :: (a -> b) -> V2 a -> V2 b #

(<$) :: a -> V2 b -> V2 a #

MonadFix V2 

Methods

mfix :: (a -> V2 a) -> V2 a #

Applicative V2 

Methods

pure :: a -> V2 a #

(<*>) :: V2 (a -> b) -> V2 a -> V2 b #

(*>) :: V2 a -> V2 b -> V2 b #

(<*) :: V2 a -> V2 b -> V2 a #

Foldable V2 

Methods

fold :: Monoid m => V2 m -> m #

foldMap :: Monoid m => (a -> m) -> V2 a -> m #

foldr :: (a -> b -> b) -> b -> V2 a -> b #

foldr' :: (a -> b -> b) -> b -> V2 a -> b #

foldl :: (b -> a -> b) -> b -> V2 a -> b #

foldl' :: (b -> a -> b) -> b -> V2 a -> b #

foldr1 :: (a -> a -> a) -> V2 a -> a #

foldl1 :: (a -> a -> a) -> V2 a -> a #

toList :: V2 a -> [a] #

null :: V2 a -> Bool #

length :: V2 a -> Int #

elem :: Eq a => a -> V2 a -> Bool #

maximum :: Ord a => V2 a -> a #

minimum :: Ord a => V2 a -> a #

sum :: Num a => V2 a -> a #

product :: Num a => V2 a -> a #

Traversable V2 

Methods

traverse :: Applicative f => (a -> f b) -> V2 a -> f (V2 b) #

sequenceA :: Applicative f => V2 (f a) -> f (V2 a) #

mapM :: Monad m => (a -> m b) -> V2 a -> m (V2 b) #

sequence :: Monad m => V2 (m a) -> m (V2 a) #

Generic1 V2 

Associated Types

type Rep1 (V2 :: * -> *) :: * -> * #

Methods

from1 :: V2 a -> Rep1 V2 a #

to1 :: Rep1 V2 a -> V2 a #

Apply V2 

Methods

(<.>) :: V2 (a -> b) -> V2 a -> V2 b #

(.>) :: V2 a -> V2 b -> V2 b #

(<.) :: V2 a -> V2 b -> V2 a #

Distributive V2 

Methods

distribute :: Functor f => f (V2 a) -> V2 (f a) #

collect :: Functor f => (a -> V2 b) -> f a -> V2 (f b) #

distributeM :: Monad m => m (V2 a) -> V2 (m a) #

collectM :: Monad m => (a -> V2 b) -> m a -> V2 (m b) #

Representable V2 

Associated Types

type Rep (V2 :: * -> *) :: * #

Methods

tabulate :: (Rep V2 -> a) -> V2 a #

index :: V2 a -> Rep V2 -> a #

Eq1 V2 

Methods

liftEq :: (a -> b -> Bool) -> V2 a -> V2 b -> Bool #

Ord1 V2 

Methods

liftCompare :: (a -> b -> Ordering) -> V2 a -> V2 b -> Ordering #

Read1 V2 

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (V2 a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [V2 a] #

Show1 V2 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> V2 a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [V2 a] -> ShowS #

MonadZip V2 

Methods

mzip :: V2 a -> V2 b -> V2 (a, b) #

mzipWith :: (a -> b -> c) -> V2 a -> V2 b -> V2 c #

munzip :: V2 (a, b) -> (V2 a, V2 b) #

Serial1 V2 

Methods

serializeWith :: MonadPut m => (a -> m ()) -> V2 a -> m () #

deserializeWith :: MonadGet m => m a -> m (V2 a) #

Additive V2 

Methods

zero :: Num a => V2 a #

(^+^) :: Num a => V2 a -> V2 a -> V2 a #

(^-^) :: Num a => V2 a -> V2 a -> V2 a #

lerp :: Num a => a -> V2 a -> V2 a -> V2 a #

liftU2 :: (a -> a -> a) -> V2 a -> V2 a -> V2 a #

liftI2 :: (a -> b -> c) -> V2 a -> V2 b -> V2 c #

Traversable1 V2 

Methods

traverse1 :: Apply f => (a -> f b) -> V2 a -> f (V2 b) #

sequence1 :: Apply f => V2 (f b) -> f (V2 b) #

Affine V2 

Associated Types

type Diff (V2 :: * -> *) :: * -> * #

Methods

(.-.) :: Num a => V2 a -> V2 a -> Diff V2 a #

(.+^) :: Num a => V2 a -> Diff V2 a -> V2 a #

(.-^) :: Num a => V2 a -> Diff V2 a -> V2 a #

R2 V2 

Methods

_y :: Functor f => (a -> f a) -> V2 a -> f (V2 a) #

_xy :: Functor f => (V2 a -> f (V2 a)) -> V2 a -> f (V2 a) #

R1 V2 

Methods

_x :: Functor f => (a -> f a) -> V2 a -> f (V2 a) #

Finite V2 

Associated Types

type Size (V2 :: * -> *) :: Nat #

Methods

toV :: V2 a -> V Nat (Size V2) a #

fromV :: V Nat (Size V2) a -> V2 a #

Metric V2 

Methods

dot :: Num a => V2 a -> V2 a -> a #

quadrance :: Num a => V2 a -> a #

qd :: Num a => V2 a -> V2 a -> a #

distance :: Floating a => V2 a -> V2 a -> a #

norm :: Floating a => V2 a -> a #

signorm :: Floating a => V2 a -> V2 a #

Bind V2 

Methods

(>>-) :: V2 a -> (a -> V2 b) -> V2 b #

join :: V2 (V2 a) -> V2 a #

Foldable1 V2 

Methods

fold1 :: Semigroup m => V2 m -> m #

foldMap1 :: Semigroup m => (a -> m) -> V2 a -> m #

toNonEmpty :: V2 a -> NonEmpty a #

HasR V2 # 

Methods

_r :: RealFloat n => Lens' (V2 n) n #

Unbox a => Vector Vector (V2 a) 

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (V2 a) -> m (Vector (V2 a)) #

basicUnsafeThaw :: PrimMonad m => Vector (V2 a) -> m (Mutable Vector (PrimState m) (V2 a)) #

basicLength :: Vector (V2 a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (V2 a) -> Vector (V2 a) #

basicUnsafeIndexM :: Monad m => Vector (V2 a) -> Int -> m (V2 a) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (V2 a) -> Vector (V2 a) -> m () #

elemseq :: Vector (V2 a) -> V2 a -> b -> b #

Unbox a => MVector MVector (V2 a) 

Methods

basicLength :: MVector s (V2 a) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (V2 a) -> MVector s (V2 a) #

basicOverlaps :: MVector s (V2 a) -> MVector s (V2 a) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (V2 a)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (V2 a) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> V2 a -> m (MVector (PrimState m) (V2 a)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (V2 a) -> Int -> m (V2 a) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (V2 a) -> Int -> V2 a -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (V2 a) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (V2 a) -> V2 a -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (V2 a) -> MVector (PrimState m) (V2 a) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (V2 a) -> MVector (PrimState m) (V2 a) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (V2 a) -> Int -> m (MVector (PrimState m) (V2 a)) #

Bounded a => Bounded (V2 a) 

Methods

minBound :: V2 a #

maxBound :: V2 a #

Eq a => Eq (V2 a) 

Methods

(==) :: V2 a -> V2 a -> Bool #

(/=) :: V2 a -> V2 a -> Bool #

Floating a => Floating (V2 a) 

Methods

pi :: V2 a #

exp :: V2 a -> V2 a #

log :: V2 a -> V2 a #

sqrt :: V2 a -> V2 a #

(**) :: V2 a -> V2 a -> V2 a #

logBase :: V2 a -> V2 a -> V2 a #

sin :: V2 a -> V2 a #

cos :: V2 a -> V2 a #

tan :: V2 a -> V2 a #

asin :: V2 a -> V2 a #

acos :: V2 a -> V2 a #

atan :: V2 a -> V2 a #

sinh :: V2 a -> V2 a #

cosh :: V2 a -> V2 a #

tanh :: V2 a -> V2 a #

asinh :: V2 a -> V2 a #

acosh :: V2 a -> V2 a #

atanh :: V2 a -> V2 a #

log1p :: V2 a -> V2 a #

expm1 :: V2 a -> V2 a #

log1pexp :: V2 a -> V2 a #

log1mexp :: V2 a -> V2 a #

Fractional a => Fractional (V2 a) 

Methods

(/) :: V2 a -> V2 a -> V2 a #

recip :: V2 a -> V2 a #

fromRational :: Rational -> V2 a #

Data a => Data (V2 a) 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> V2 a -> c (V2 a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (V2 a) #

toConstr :: V2 a -> Constr #

dataTypeOf :: V2 a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (V2 a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V2 a)) #

gmapT :: (forall b. Data b => b -> b) -> V2 a -> V2 a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V2 a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V2 a -> r #

gmapQ :: (forall d. Data d => d -> u) -> V2 a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> V2 a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> V2 a -> m (V2 a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> V2 a -> m (V2 a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> V2 a -> m (V2 a) #

Num a => Num (V2 a) 

Methods

(+) :: V2 a -> V2 a -> V2 a #

(-) :: V2 a -> V2 a -> V2 a #

(*) :: V2 a -> V2 a -> V2 a #

negate :: V2 a -> V2 a #

abs :: V2 a -> V2 a #

signum :: V2 a -> V2 a #

fromInteger :: Integer -> V2 a #

Ord a => Ord (V2 a) 

Methods

compare :: V2 a -> V2 a -> Ordering #

(<) :: V2 a -> V2 a -> Bool #

(<=) :: V2 a -> V2 a -> Bool #

(>) :: V2 a -> V2 a -> Bool #

(>=) :: V2 a -> V2 a -> Bool #

max :: V2 a -> V2 a -> V2 a #

min :: V2 a -> V2 a -> V2 a #

Read a => Read (V2 a) 
Show a => Show (V2 a) 

Methods

showsPrec :: Int -> V2 a -> ShowS #

show :: V2 a -> String #

showList :: [V2 a] -> ShowS #

Ix a => Ix (V2 a) 

Methods

range :: (V2 a, V2 a) -> [V2 a] #

index :: (V2 a, V2 a) -> V2 a -> Int #

unsafeIndex :: (V2 a, V2 a) -> V2 a -> Int

inRange :: (V2 a, V2 a) -> V2 a -> Bool #

rangeSize :: (V2 a, V2 a) -> Int #

unsafeRangeSize :: (V2 a, V2 a) -> Int

Generic (V2 a) 

Associated Types

type Rep (V2 a) :: * -> * #

Methods

from :: V2 a -> Rep (V2 a) x #

to :: Rep (V2 a) x -> V2 a #

Storable a => Storable (V2 a) 

Methods

sizeOf :: V2 a -> Int #

alignment :: V2 a -> Int #

peekElemOff :: Ptr (V2 a) -> Int -> IO (V2 a) #

pokeElemOff :: Ptr (V2 a) -> Int -> V2 a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (V2 a) #

pokeByteOff :: Ptr b -> Int -> V2 a -> IO () #

peek :: Ptr (V2 a) -> IO (V2 a) #

poke :: Ptr (V2 a) -> V2 a -> IO () #

Binary a => Binary (V2 a) 

Methods

put :: V2 a -> Put #

get :: Get (V2 a) #

putList :: [V2 a] -> Put #

Serial a => Serial (V2 a) 

Methods

serialize :: MonadPut m => V2 a -> m () #

deserialize :: MonadGet m => m (V2 a) #

Serialize a => Serialize (V2 a) 

Methods

put :: Putter (V2 a) #

get :: Get (V2 a) #

NFData a => NFData (V2 a) 

Methods

rnf :: V2 a -> () #

Hashable a => Hashable (V2 a) 

Methods

hashWithSalt :: Int -> V2 a -> Int #

hash :: V2 a -> Int #

Unbox a => Unbox (V2 a) 
Ixed (V2 a) 

Methods

ix :: Index (V2 a) -> Traversal' (V2 a) (IxValue (V2 a)) #

Epsilon a => Epsilon (V2 a) 

Methods

nearZero :: V2 a -> Bool #

Coordinates (V2 n) # 

Associated Types

type FinalCoord (V2 n) :: * #

type PrevDim (V2 n) :: * #

type Decomposition (V2 n) :: * #

Methods

(^&) :: PrevDim (V2 n) -> FinalCoord (V2 n) -> V2 n #

pr :: PrevDim (V2 n) -> FinalCoord (V2 n) -> V2 n #

coords :: V2 n -> Decomposition (V2 n) #

FunctorWithIndex (E V2) V2 

Methods

imap :: (E V2 -> a -> b) -> V2 a -> V2 b #

imapped :: (Indexable (E V2) p, Settable f) => p a (f b) -> V2 a -> f (V2 b) #

FoldableWithIndex (E V2) V2 

Methods

ifoldMap :: Monoid m => (E V2 -> a -> m) -> V2 a -> m #

ifolded :: (Indexable (E V2) p, Contravariant f, Applicative f) => p a (f a) -> V2 a -> f (V2 a) #

ifoldr :: (E V2 -> a -> b -> b) -> b -> V2 a -> b #

ifoldl :: (E V2 -> b -> a -> b) -> b -> V2 a -> b #

ifoldr' :: (E V2 -> a -> b -> b) -> b -> V2 a -> b #

ifoldl' :: (E V2 -> b -> a -> b) -> b -> V2 a -> b #

TraversableWithIndex (E V2) V2 

Methods

itraverse :: Applicative f => (E V2 -> a -> f b) -> V2 a -> f (V2 b) #

itraversed :: (Indexable (E V2) p, Applicative f) => p a (f b) -> V2 a -> f (V2 b) #

Each (V2 a) (V2 b) a b 

Methods

each :: Traversal (V2 a) (V2 b) a b #

RealFloat n => Traced (BoundingBox V2 n) # 

Methods

getTrace :: BoundingBox V2 n -> Trace (V (BoundingBox V2 n)) (N (BoundingBox V2 n)) #

type Rep1 V2 
type Rep V2 
type Rep V2 = E V2
type Diff V2 
type Diff V2 = V2
type Size V2 
type Size V2 = 2
data MVector s (V2 a) 
data MVector s (V2 a) = MV_V2 ~Int ~(MVector s a)
type Rep (V2 a) 
type V (V2 n) # 
type V (V2 n) = V2
type N (V2 n) # 
type N (V2 n) = n
data Vector (V2 a) 
data Vector (V2 a) = V_V2 ~Int ~(Vector a)
type Index (V2 a) 
type Index (V2 a) = E V2
type IxValue (V2 a) 
type IxValue (V2 a) = a
type FinalCoord (V2 n) # 
type FinalCoord (V2 n) = n
type PrevDim (V2 n) # 
type PrevDim (V2 n) = n
type Decomposition (V2 n) # 
type Decomposition (V2 n) = (:&) n n

class R1 t where #

A space that has at least 1 basis vector _x.

Methods

_x :: Functor f => (a -> f a) -> t a -> f (t a) #

>>> V1 2 ^._x
2
>>> V1 2 & _x .~ 3
V1 3

Instances

R1 Identity 

Methods

_x :: Functor f => (a -> f a) -> Identity a -> f (Identity a) #

R1 V4 

Methods

_x :: Functor f => (a -> f a) -> V4 a -> f (V4 a) #

R1 V3 

Methods

_x :: Functor f => (a -> f a) -> V3 a -> f (V3 a) #

R1 V2 

Methods

_x :: Functor f => (a -> f a) -> V2 a -> f (V2 a) #

R1 V1 

Methods

_x :: Functor f => (a -> f a) -> V1 a -> f (V1 a) #

R1 f => R1 (Point f) 

Methods

_x :: Functor f => (a -> f a) -> Point f a -> f (Point f a) #

class R1 t => R2 t where #

A space that distinguishes 2 orthogonal basis vectors _x and _y, but may have more.

Methods

_y :: Functor f => (a -> f a) -> t a -> f (t a) #

>>> V2 1 2 ^._y
2
>>> V2 1 2 & _y .~ 3
V2 1 3

_xy :: Functor f => (V2 a -> f (V2 a)) -> t a -> f (t a) #

Instances

R2 V4 

Methods

_y :: Functor f => (a -> f a) -> V4 a -> f (V4 a) #

_xy :: Functor f => (V2 a -> f (V2 a)) -> V4 a -> f (V4 a) #

R2 V3 

Methods

_y :: Functor f => (a -> f a) -> V3 a -> f (V3 a) #

_xy :: Functor f => (V2 a -> f (V2 a)) -> V3 a -> f (V3 a) #

R2 V2 

Methods

_y :: Functor f => (a -> f a) -> V2 a -> f (V2 a) #

_xy :: Functor f => (V2 a -> f (V2 a)) -> V2 a -> f (V2 a) #

R2 f => R2 (Point f) 

Methods

_y :: Functor f => (a -> f a) -> Point f a -> f (Point f a) #

_xy :: Functor f => (V2 a -> f (V2 a)) -> Point f a -> f (Point f a) #

type P2 = Point V2 #

r2 :: (n, n) -> V2 n #

Construct a 2D vector from a pair of components. See also &.

unr2 :: V2 n -> (n, n) #

Convert a 2D vector back into a pair of components. See also coords.

mkR2 :: n -> n -> V2 n #

Curried form of r2.

p2 :: (n, n) -> P2 n #

Construct a 2D point from a pair of coordinates. See also ^&.

unp2 :: P2 n -> (n, n) #

Convert a 2D point back into a pair of coordinates. See also coords.

mkP2 :: n -> n -> P2 n #

Curried form of p2.

unitX :: (R1 v, Additive v, Num n) => v n #

The unit vector in the positive X direction.

unitY :: (R2 v, Additive v, Num n) => v n #

The unit vector in the positive Y direction.

unit_X :: (R1 v, Additive v, Num n) => v n #

The unit vector in the negative X direction.

unit_Y :: (R2 v, Additive v, Num n) => v n #

The unit vector in the negative Y direction.

perp :: Num a => V2 a -> V2 a #

the counter-clockwise perpendicular vector

>>> perp $ V2 10 20
V2 (-20) 10

leftTurn :: (Num n, Ord n) => V2 n -> V2 n -> Bool #

leftTurn v1 v2 tests whether the direction of v2 is a left turn from v1 (that is, if the direction of v2 can be obtained from that of v1 by adding an angle 0 <= theta <= tau/2).

xDir :: (R1 v, Additive v, Num n) => Direction v n #

A Direction pointing in the X direction.

yDir :: (R2 v, Additive v, Num n) => Direction v n #

A Direction pointing in the Y direction.

Angles

tau :: Floating a => a #

The circle constant, the ratio of a circle's circumference to its radius. Note that pi = tau/2.

For more information and a well-reasoned argument why we should all be using tau instead of pi, see The Tau Manifesto, http://tauday.com/.

To hear what it sounds like (and to easily memorize the first 30 digits or so), try http://youtu.be/3174T-3-59Q.

angleV :: Floating n => Angle n -> V2 n #

A unit vector at a specified angle counter-clockwise from the positive x-axis

angleDir :: Floating n => Angle n -> Direction V2 n #

A direction at a specified angle counter-clockwise from the xDir.

signedAngleBetween :: RealFloat n => V2 n -> V2 n -> Angle n #

Signed angle between two vectors. Currently defined as

signedAngleBetween u v = (u ^. _theta) ^-^ (v ^. _theta)

signedAngleBetweenDirs :: RealFloat n => Direction V2 n -> Direction V2 n -> Angle n #

Same as signedAngleBetween but for Directionss.

Polar Coördinates

class HasR t where #

A space which has magnitude _r that can be calculated numerically.

Methods

_r :: RealFloat n => Lens' (t n) n #

Instances

HasR V2 # 

Methods

_r :: RealFloat n => Lens' (V2 n) n #

HasR v => HasR (Point v) # 

Methods

_r :: RealFloat n => Lens' (Point v n) n #

r2PolarIso :: RealFloat n => Iso' (V2 n) (n, Angle n) #

Paths

Stroking

stroke :: (InSpace V2 n t, ToPath t, TypeableFloat n, Renderable (Path V2 n) b) => t -> QDiagram b V2 n Any #

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 b
stroke :: Located (Trail V2 Double)       -> Diagram b
stroke :: Located (Trail' Loop V2 Double) -> Diagram b
stroke :: 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 #

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' (with & ... ) syntax may be used.

strokePath :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any #

stroke specialised to Path.

strokeP :: (TypeableFloat n, Renderable (Path V2 n) b) => Path V2 n -> QDiagram b V2 n Any #

stroke specialised to Path.

strokePath' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any #

stroke' specialised to Path.

strokeP' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Path V2 n -> QDiagram b V2 n Any #

stroke' specialised to Path.

strokeTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any #

stroke specialised to Trail.

strokeT :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail V2 n -> QDiagram b V2 n Any #

stroke specialised to Trail.

strokeTrail' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName a) => StrokeOpts a -> Trail V2 n -> QDiagram b V2 n Any #

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 #

Deprecated synonym for strokeTrail'.

strokeLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Line V2 n -> QDiagram b V2 n Any #

A composition of strokeT and wrapLine for conveniently converting a line directly into a diagram.

strokeLoop :: (TypeableFloat n, Renderable (Path V2 n) b) => Trail' Loop V2 n -> QDiagram b V2 n Any #

A composition of strokeT and wrapLoop for conveniently converting a loop directly into a diagram.

strokeLocTrail :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail V2 n) -> QDiagram b V2 n Any #

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 #

Deprecated synonym for strokeLocTrail.

strokeLocLine :: (TypeableFloat n, Renderable (Path V2 n) b) => Located (Trail' Line V2 n) -> QDiagram b V2 n Any #

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 #

A convenience function for converting a Located loop directly into a diagram; strokeLocLoop = stroke . trailLike . mapLoc wrapLoop.

data FillRule #

Enumeration of algorithms or "rules" for determining which points lie in the interior of a (possibly self-intersecting) path.

Constructors

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.

fillRule :: HasStyle a => FillRule -> a -> a #

Specify the fill rule that should be used for determining which points are inside a path.

_fillRule :: Lens' (Style V2 n) FillRule #

Lens onto the fill rule of a style.

data StrokeOpts a #

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 with { ... } notation.

Constructors

StrokeOpts 

Fields

Instances

Default (StrokeOpts a) # 

Methods

def :: StrokeOpts a #

vertexNames :: Lens (StrokeOpts a) (StrokeOpts a') [[a]] [[a']] #

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 #

The fill rule used for determining which points are inside the path. The default is Winding. NOTE: for now, this only affects the resulting diagram's Query, not how it will be drawn! To set the fill rule determining how it is to be drawn, use the fillRule function.

intersectPoints :: (InSpace V2 n t, SameSpace t s, ToPath t, ToPath s, OrderedField n) => t -> s -> [P2 n] #

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] #

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] #

Compute the intersect points between two paths.

intersectPointsP' :: OrderedField n => n -> Path V2 n -> Path V2 n -> [P2 n] #

Compute the intersect points between two paths within given tolerance.

intersectPointsT :: OrderedField n => Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n] #

Compute the intersect points between two located trails.

intersectPointsT' :: OrderedField n => n -> Located (Trail V2 n) -> Located (Trail V2 n) -> [P2 n] #

Compute the intersect points between two located trails within the given tolerance.

Clipping

clipBy :: (HasStyle a, V a ~ V2, N a ~ n, TypeableFloat n) => Path V2 n -> a -> a #

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 #

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 #

Clip a diagram to the clip path taking the envelope and trace of the clip path.

_Clip :: Iso (Clip n) (Clip n') [Path V2 n] [Path V2 n'] #

_clip :: (Typeable n, OrderedField n) => Lens' (Style V2 n) [Path V2 n] #

Lens onto the Clip in a style. An empty list means no clipping.

Shapes

Rules

hrule :: (InSpace V2 n t, TrailLike t) => n -> t #

Create a centered horizontal (L-R) line of the given length.

hruleEx = vcat' (with & sep .~ 0.2) (map hrule [1..5])
        # centerXY # pad 1.1

vrule :: (InSpace V2 n t, TrailLike t) => n -> t #

Create a centered vertical (T-B) line of the given length.

vruleEx = hcat' (with & sep .~ 0.2) (map vrule [1, 1.2 .. 2])
        # centerXY # pad 1.1

Circle-ish things

unitCircle :: (TrailLike t, V t ~ V2, N t ~ n) => t #

A circle of radius 1, with center at the origin.

circle :: (TrailLike t, V t ~ V2, N t ~ n, Transformable t) => n -> t #

A circle of the given radius, centered at the origin. As a path, it begins at (r,0).

ellipse :: (TrailLike t, V t ~ V2, N t ~ n, Transformable t) => n -> t #

ellipse e constructs an ellipse with eccentricity e by scaling the unit circle in the X direction. The eccentricity must be within the interval [0,1).

ellipseXY :: (TrailLike t, V t ~ V2, N t ~ n, Transformable t) => n -> n -> t #

ellipseXY x y creates an axis-aligned ellipse, centered at the origin, with radius x along the x-axis and radius y along the y-axis.

arc :: (InSpace V2 n t, OrderedField n, TrailLike t) => Direction V2 n -> Angle n -> t #

Given a start direction d and a sweep angle s, arc d s is the path of a radius one arc starting at d and sweeping out the angle s counterclockwise (for positive s). The resulting Trail is allowed to wrap around and overlap itself.

arc' :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t #

Given a radus r, a start direction d and an angle s, arc' r d s is the path of a radius (abs r) arc starting at d and sweeping out the angle s counterclockwise (for positive s). The origin of the arc is its center.

arc'Ex = mconcat [ arc' r xDir (1/4 @@ turn) | r <- [0.5,-1,1.5] ]
       # centerXY # pad 1.1

arcCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t #

Like arcAngleCCW but clockwise.

arcCCW :: (InSpace V2 n t, RealFloat n, TrailLike t) => Direction V2 n -> Direction V2 n -> t #

Given a start direction s and end direction e, arcCCW s e is the path of a radius one arc counterclockwise between the two directions. The origin of the arc is its center.

wedge :: (InSpace V2 n t, OrderedField n, TrailLike t) => n -> Direction V2 n -> Angle n -> t #

Create a circular wedge of the given radius, beginning at the given direction and extending through the given angle.

wedgeEx = hcat' (with & sep .~ 0.5)
  [ wedge 1 xDir (1/4 @@ turn)
  , wedge 1 (rotate (7/30 @@ turn) xDir) (4/30 @@ turn)
  , wedge 1 (rotate (1/8 @@ turn) xDir) (3/4 @@ turn)
  ]
  # fc blue
  # centerXY # pad 1.1

arcBetween :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => Point V2 n -> Point V2 n -> n -> t #

arcBetween p q height creates an arc beginning at p and ending at q, with its midpoint at a distance of abs height away from the straight line from p to q. A positive value of height results in an arc to the left of the line from p to q; a negative value yields one to the right.

arcBetweenEx = mconcat
  [ arcBetween origin (p2 (2,1)) ht | ht <- [-0.2, -0.1 .. 0.2] ]
  # centerXY # pad 1.1

annularWedge :: (TrailLike t, V t ~ V2, N t ~ n, RealFloat n) => n -> n -> Direction V2 n -> Angle n -> t #

Create an annular wedge of the given radii, beginning at the first direction and extending through the given sweep angle. The radius of the outer circle is given first.

annularWedgeEx = hsep 0.50
  [ annularWedge 1 0.5 xDir (1/4 @@ turn)
  , annularWedge 1 0.3 (rotate (7/30 @@ turn) xDir) (4/30 @@ turn)
  , annularWedge 1 0.7 (rotate (1/8 @@ turn) xDir) (3/4 @@ turn)
  ]
  # fc blue
  # centerXY # pad 1.1

General polygons

polygon :: (InSpace V2 n t, TrailLike t) => PolygonOpts n -> t #

Generate the polygon described by the given options.

polyTrail :: OrderedField n => PolygonOpts n -> Located (Trail V2 n) #

Generate a polygon. See PolygonOpts for more information.

data PolygonOpts n #

Options for specifying a polygon.

Instances

Num n => Default (PolygonOpts n) #

The default polygon is a regular pentagon of radius 1, centered at the origin, aligned to the x-axis.

Methods

def :: PolygonOpts n #

polyType :: Lens' (PolygonOpts n) (PolyType n) #

Specification for the polygon's vertices.

polyOrient :: Lens' (PolygonOpts n) (PolyOrientation n) #

Should a rotation be applied to the polygon in order to orient it in a particular way?

polyCenter :: Lens' (PolygonOpts n) (Point V2 n) #

Should a translation be applied to the polygon in order to place the center at a particular location?

data PolyType n #

Method used to determine the vertices of a polygon.

Constructors

PolyPolar [Angle n] [n]

A "polar" polygon.

  • The first argument is a list of central angles from each vertex to the next.
  • The second argument is a list of radii from the origin to each successive vertex.

To construct an n-gon, use a list of n-1 angles and n radii. Extra angles or radii are ignored.

Cyclic polygons (with all vertices lying on a circle) can be constructed using a second argument of (repeat r).

PolySides [Angle n] [n]

A polygon determined by the distance between successive vertices and the external angles formed by each three successive vertices. In other words, a polygon specified by "turtle graphics": go straight ahead x1 units; turn by external angle a1; go straight ahead x2 units; turn by external angle a2; etc. The polygon will be centered at the centroid of its vertices.

  • The first argument is a list of vertex angles, giving the external angle at each vertex from the previous vertex to the next. The first angle in the list is the external angle at the second vertex; the first edge always starts out heading in the positive y direction from the first vertex.
  • The second argument is a list of distances between successive vertices.

To construct an n-gon, use a list of n-2 angles and n-1 edge lengths. Extra angles or lengths are ignored.

PolyRegular Int n

A regular polygon with the given number of sides (first argument) and the given radius (second argument).

data PolyOrientation n #

Determine how a polygon should be oriented.

Constructors

NoOrient

No special orientation; the first vertex will be at (1,0). This is the default.

OrientH

Orient horizontally, so the bottommost edge is parallel to the x-axis.

OrientV

Orient vertically, so the leftmost edge is parallel to the y-axis.

OrientTo (V2 n)

Orient so some edge is facing in the direction of, that is, perpendicular to, the given vector.

Star polygons

data StarOpts #

Options for creating "star" polygons, where the edges connect possibly non-adjacent vertices.

Constructors

StarFun (Int -> Int)

Specify the order in which the vertices should be connected by a function that maps each vertex index to the index of the vertex that should come next. Indexing of vertices begins at 0.

StarSkip Int

Specify a star polygon by a "skip". A skip of 1 indicates a normal polygon, where edges go between successive vertices. A skip of 2 means that edges will connect every second vertex, skipping one in between. Generally, a skip of n means that edges will connect every nth vertex.

star :: OrderedField n => StarOpts -> [Point V2 n] -> Path V2 n #

Create a generalized star polygon. The StarOpts are used to determine in which order the given vertices should be connected. The intention is that the second argument of type [Point v] could be generated by a call to polygon, regPoly, or the like, since a list of vertices is TrailLike. But of course the list can be generated any way you like. A Path v is returned (instead of any TrailLike) because the resulting path may have more than one component, for example if the vertices are to be connected in several disjoint cycles.

Regular polygons

regPoly :: (InSpace V2 n t, TrailLike t) => Int -> n -> t #

Create a regular polygon. The first argument is the number of sides, and the second is the length of the sides. (Compare to the polygon function with a PolyRegular option, which produces polygons of a given radius).

The polygon will be oriented with one edge parallel to the x-axis.

triangle :: (InSpace V2 n t, TrailLike t) => n -> t #

An equilateral triangle, with sides of the given length and base parallel to the x-axis.

eqTriangle :: (InSpace V2 n t, TrailLike t) => n -> t #

A synonym for triangle, provided for backwards compatibility.

square :: (InSpace V2 n t, TrailLike t) => n -> t #

A square with its center at the origin and sides of the given length, oriented parallel to the axes.

pentagon :: (InSpace V2 n t, TrailLike t) => n -> t #

A regular pentagon, with sides of the given length and base parallel to the x-axis.

hexagon :: (InSpace V2 n t, TrailLike t) => n -> t #

A regular hexagon, with sides of the given length and base parallel to the x-axis.

heptagon :: (InSpace V2 n t, TrailLike t) => n -> t #

A regular heptagon, with sides of the given length and base parallel to the x-axis.

septagon :: (InSpace V2 n t, TrailLike t) => n -> t #

A synonym for heptagon. It is, however, completely inferior, being a base admixture of the Latin septum (seven) and the Greek γωνία (angle).

octagon :: (InSpace V2 n t, TrailLike t) => n -> t #

A regular octagon, with sides of the given length and base parallel to the x-axis.

nonagon :: (InSpace V2 n t, TrailLike t) => n -> t #

A regular nonagon, with sides of the given length and base parallel to the x-axis.

decagon :: (InSpace V2 n t, TrailLike t) => n -> t #

A regular decagon, with sides of the given length and base parallel to the x-axis.

hendecagon :: (InSpace V2 n t, TrailLike t) => n -> t #

A regular hendecagon, with sides of the given length and base parallel to the x-axis.

dodecagon :: (InSpace V2 n t, TrailLike t) => n -> t #

A regular dodecagon, with sides of the given length and base parallel to the x-axis.

Other special polygons

unitSquare :: (InSpace V2 n t, TrailLike t) => t #

A square with its center at the origin and sides of length 1, oriented parallel to the axes.

rect :: (InSpace V2 n t, TrailLike t) => n -> n -> t #

rect w h is an axis-aligned rectangle of width w and height h, centered at the origin.

Other shapes

roundedRect :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> n -> t #

roundedRect w h r generates a closed trail, or closed path centered at the origin, of an axis-aligned rectangle with width w, height h, and circular rounded corners of radius r. If r is negative the corner will be cut out in a reverse arc. If the size of r is larger than half the smaller dimension of w and h, then it will be reduced to fit in that range, to prevent the corners from overlapping. The trail or path begins with the right edge and proceeds counterclockwise. If you need to specify a different radius for each corner individually, use roundedRect' instead.

roundedRectEx = pad 1.1 . centerXY $ hcat' (with & sep .~ 0.2)
  [ roundedRect  0.5 0.4 0.1
  , roundedRect  0.5 0.4 (-0.1)
  , roundedRect' 0.7 0.4 (with & radiusTL .~ 0.2
                               & radiusTR .~ -0.2
                               & radiusBR .~ 0.1)
  ]

roundedRect' :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> RoundedRectOpts n -> t #

roundedRect' works like roundedRect but allows you to set the radius of each corner indivually, using RoundedRectOpts. The default corner radius is 0. Each radius can also be negative, which results in the curves being reversed to be inward instead of outward.

data RoundedRectOpts d #

Constructors

RoundedRectOpts 

Fields

Instances

radiusTL :: forall d. Lens' (RoundedRectOpts d) d #

radiusTR :: forall d. Lens' (RoundedRectOpts d) d #

radiusBL :: forall d. Lens' (RoundedRectOpts d) d #

radiusBR :: forall d. Lens' (RoundedRectOpts d) d #

Arrows

arrowV :: (TypeableFloat n, Renderable (Path V2 n) b) => V2 n -> QDiagram b V2 n Any #

arrowV v creates an arrow with the direction and norm of the vector v (with its tail at the origin), using default parameters.

arrowV' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> V2 n -> QDiagram b V2 n Any #

arrowV' v creates an arrow with the direction and norm of the vector v (with its tail at the origin).

arrowAt :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> V2 n -> QDiagram b V2 n Any #

Create an arrow starting at s with length and direction determined by the vector v.

arrowAt' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> Point V2 n -> V2 n -> QDiagram b V2 n Any #

arrowBetween :: (TypeableFloat n, Renderable (Path V2 n) b) => Point V2 n -> Point V2 n -> QDiagram b V2 n Any #

arrowBetween s e creates an arrow pointing from s to e with default parameters.

arrowBetween' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> Point V2 n -> Point V2 n -> QDiagram b V2 n Any #

arrowBetween' opts s e creates an arrow pointing from s to e using the given options. In particular, it scales and rotates arrowShaft to go between s and e, taking head, tail, and gaps into account.

connect :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any #

Connect two diagrams with a straight arrow.

connect' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any #

Connect two diagrams with an arbitrary arrow.

connectPerim :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> Angle n -> Angle n -> QDiagram b V2 n Any -> QDiagram b V2 n Any #

Connect two diagrams at point on the perimeter of the diagrams, choosen by angle.

connectPerim' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> Angle n -> Angle n -> QDiagram b V2 n Any -> QDiagram b V2 n Any #

connectOutside :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any #

Draw an arrow from diagram named "n1" to diagram named "n2". The arrow lies on the line between the centres of the diagrams, but is drawn so that it stops at the boundaries of the diagrams, using traces to find the intersection points.

connectOutside' :: (TypeableFloat n, Renderable (Path V2 n) b, IsName n1, IsName n2) => ArrowOpts n -> n1 -> n2 -> QDiagram b V2 n Any -> QDiagram b V2 n Any #

arrow :: (TypeableFloat n, Renderable (Path V2 n) b) => n -> QDiagram b V2 n Any #

arrow len creates an arrow of length len with default parameters, starting at the origin and ending at the point (len,0).

arrow' :: (TypeableFloat n, Renderable (Path V2 n) b) => ArrowOpts n -> n -> QDiagram b V2 n Any #

arrow' opts len creates an arrow of length len using the given options, starting at the origin and ending at the point (len,0). In particular, it scales the given arrowShaft so that the entire arrow has length len.

straightShaft :: OrderedField n => Trail V2 n #

Straight line arrow shaft.

arrowHead :: Lens' (ArrowOpts n) (ArrowHT n) #

A shape to place at the head of the arrow.

arrowTail :: Lens' (ArrowOpts n) (ArrowHT n) #

A shape to place at the tail of the arrow.

arrowShaft :: Lens' (ArrowOpts n) (Trail V2 n) #

The trail to use for the arrow shaft.

headGap :: Lens' (ArrowOpts n) (Measure n) #

Distance to leave between the head and the target point.

tailGap :: Lens' (ArrowOpts n) (Measure n) #

Distance to leave between the starting point and the tail.

gaps :: Traversal' (ArrowOpts n) (Measure n) #

Set both the headGap and tailGap simultaneously.

gap :: Traversal' (ArrowOpts n) (Measure n) #

Same as gaps, provided for backward compatiiblity.

headTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n) #

A lens for setting or modifying the texture of an arrowhead. For example, one may write ... (with & headTexture .~ grad) to get an arrow with a head filled with a gradient, assuming grad has been defined. Or ... (with & headTexture .~ solid blue to set the head color to blue. For more general control over the style of arrowheads, see headStyle.

headStyle :: Lens' (ArrowOpts n) (Style V2 n) #

Style to apply to the head. headStyle is modified by using the lens combinator %~ to change the current style. For example, to change an opaque black arrowhead to translucent orange: (with & headStyle %~ fc orange . opacity 0.75).

tailTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n) #

A lens for setting or modifying the texture of an arrow tail. This is *not* a valid lens (see committed).

tailStyle :: Lens' (ArrowOpts n) (Style V2 n) #

Style to apply to the tail. See headStyle.

shaftTexture :: TypeableFloat n => Lens' (ArrowOpts n) (Texture n) #

A lens for setting or modifying the texture of an arrow shaft.

shaftStyle :: Lens' (ArrowOpts n) (Style V2 n) #

Style to apply to the shaft. See headStyle.

headLength :: Lens' (ArrowOpts n) (Measure n) #

The length from the start of the joint to the tip of the head.

tailLength :: Lens' (ArrowOpts n) (Measure n) #

The length of the tail plus its joint.

lengths :: Traversal' (ArrowOpts n) (Measure n) #

Set both the headLength and tailLength simultaneously.

Text

text :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any #

Create a primitive text diagram from the given string, with center alignment, equivalent to alignedText 0.5 0.5.

Note that it takes up no space, as text size information is not available.

topLeftText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any #

Create a primitive text diagram from the given string, origin at the top left corner of the text's bounding box, equivalent to alignedText 0 1.

Note that it takes up no space.

alignedText :: (TypeableFloat n, Renderable (Text n) b) => n -> n -> String -> QDiagram b V2 n Any #

Create a primitive text diagram from the given string, with the origin set to a point interpolated within the bounding box. The first parameter varies from 0 (left) to 1 (right), and the second parameter from 0 (bottom) to 1 (top). Some backends do not implement this and instead snap to closest corner or the center.

The height of this box is determined by the font's potential ascent and descent, rather than the height of the particular string.

Note that it takes up no space.

baselineText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any #

Create a primitive text diagram from the given string, with the origin set to be on the baseline, at the beginning (although not bounding). This is the reference point of showText in the Cairo graphics library.

Note that it takes up no space.

font :: HasStyle a => String -> a -> a #

Specify a font family to be used for all text within a diagram.

italic :: HasStyle a => a -> a #

Set all text in italics.

oblique :: HasStyle a => a -> a #

Set all text using an oblique slant.

fontSize :: (N a ~ n, Typeable n, HasStyle a) => Measure n -> a -> a #

Set the font size, that is, the size of the font's em-square as measured within the current local vector space. The default size is local 1 (which is applied by recommendFontSize).

bold :: HasStyle a => a -> a #

Set all text using a bold font weight.

bolder :: HasStyle a => a -> a #

Set all text to be bolder than the inherited font weight.

lighter :: HasStyle a => a -> a #

Set all text to be lighter than the inherited font weight.

thinWeight :: HasStyle a => a -> a #

Set all text using a thin font weight.

ultraLight :: HasStyle a => a -> a #

Set all text using a extra light font weight.

light :: HasStyle a => a -> a #

Set all text using a light font weight.

mediumWeight :: HasStyle a => a -> a #

Set all text using a medium font weight.

heavy :: HasStyle a => a -> a #

Set all text using a heavy/black font weight.

semiBold :: HasStyle a => a -> a #

Set all text using a semi-bold font weight.

ultraBold :: HasStyle a => a -> a #

Set all text using an ultra-bold font weight.

_font :: Lens' (Style v n) (Maybe String) #

Lens onto the font name of a style.

_fontSize :: (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n) #

Lens to commit a font size. This is *not* a valid lens (see commited.

fontSizeO :: (N a ~ n, Typeable n, HasStyle a) => n -> a -> a #

A convenient synonym for 'fontSize (Output w)'.

fontSizeL :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a #

A convenient sysnonym for 'fontSize (Local w)'.

fontSizeN :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a #

A convenient synonym for 'fontSize (Normalized w)'.

fontSizeG :: (N a ~ n, Typeable n, Num n, HasStyle a) => n -> a -> a #

A convenient synonym for 'fontSize (Global w)'.

Images

data DImage :: * -> * -> * where #

An image primitive, the two ints are width followed by height. Will typically be created by loadImageEmb or loadImageExt which, will handle setting the width and height to the actual width and height of the image.

Constructors

DImage :: ImageData t -> Int -> Int -> Transformation V2 n -> DImage n t 

Instances

Fractional n => Transformable (DImage n a) # 

Methods

transform :: Transformation (V (DImage n a)) (N (DImage n a)) -> DImage n a -> DImage n a #

Fractional n => HasOrigin (DImage n a) # 

Methods

moveOriginTo :: Point (V (DImage n a)) (N (DImage n a)) -> DImage n a -> DImage n a #

Fractional n => Renderable (DImage n a) NullBackend # 

Methods

render :: NullBackend -> DImage n a -> Render NullBackend (V (DImage n a)) (N (DImage n a)) #

RealFloat n => HasQuery (DImage n a) Any # 

Methods

getQuery :: DImage n a -> Query (V (DImage n a)) (N (DImage n a)) Any #

type V (DImage n a) # 
type V (DImage n a) = V2
type N (DImage n a) # 
type N (DImage n a) = n

data ImageData :: * -> * where #

ImageData is either a JuicyPixels DynamicImage tagged as Embedded or a reference tagged as External. Additionally Native is provided for external libraries to hook into.

data Embedded #

data External #

data Native t #

image :: (TypeableFloat n, Typeable a, Renderable (DImage n a) b) => DImage n a -> QDiagram b V2 n Any #

Make a DImage into a Diagram.

loadImageEmb :: Num n => FilePath -> IO (Either String (DImage n Embedded)) #

Use JuicyPixels to read a file in any format and wrap it in a DImage. The width and height of the image are set to their actual values.

loadImageExt :: Num n => FilePath -> IO (Either String (DImage n External)) #

Check that a file exists, and use JuicyPixels to figure out the right size, but save a reference to the image instead of the raster data

uncheckedImageRef :: Num n => FilePath -> Int -> Int -> DImage n External #

Make an "unchecked" image reference; have to specify a width and height. Unless the aspect ratio of the external image is the w :: h, then the image will be distorted.

raster :: Num n => (Int -> Int -> AlphaColour Double) -> Int -> Int -> DImage n Embedded #

Create an image "from scratch" by specifying the pixel data

rasterDia :: (TypeableFloat n, Renderable (DImage n Embedded) b) => (Int -> Int -> AlphaColour Double) -> Int -> Int -> QDiagram b V2 n Any #

Crate a diagram from raw raster data.

Transformations

Rotation

rotation :: Floating n => Angle n -> Transformation V2 n #

Create a transformation which performs a rotation about the local origin by the given angle. See also rotate.

rotate :: (InSpace V2 n t, Transformable t, Floating n) => Angle n -> t -> t #

Rotate about the local origin by the given angle. Positive angles correspond to counterclockwise rotation, negative to clockwise. The angle can be expressed using any of the Isos on Angle. For example, rotate (1/4 @@ turn), rotate (tau/4 @@ rad), and rotate (90 @@ deg) all represent the same transformation, namely, a counterclockwise rotation by a right angle. To rotate about some point other than the local origin, see rotateAbout.

Note that writing rotate (1/4), with no Angle constructor, will yield an error since GHC cannot figure out which sort of angle you want to use. In this common situation you can use rotateBy, which interprets its argument as a number of turns.

rotateBy :: (InSpace V2 n t, Transformable t, Floating n) => n -> t -> t #

A synonym for rotate, interpreting its argument in units of turns; it can be more convenient to write rotateBy (1/4) than rotate (1/4 @@ turn).

rotated :: (InSpace V2 n a, Floating n, SameSpace a b, Transformable a, Transformable b) => Angle n -> Iso a b a b #

Use an Angle to make an Iso between an object rotated and unrotated. This us useful for performing actions under a rotation:

under (rotated t) f = rotate (negated t) . f . rotate t
rotated t ## a      = rotate t a
a ^. rotated t      = rotate (-t) a
over (rotated t) f  = rotate t . f . rotate (negated t)

rotationAround :: Floating n => P2 n -> Angle n -> T2 n #

rotationAbout p is a rotation about the point p (instead of around the local origin).

rotateAround :: (InSpace V2 n t, Transformable t, Floating n) => P2 n -> Angle n -> t -> t #

rotateAbout p is like rotate, except it rotates around the point p instead of around the local origin.

rotationTo :: OrderedField n => Direction V2 n -> T2 n #

The rotation that aligns the x-axis with the given direction.

rotateTo :: (InSpace V2 n t, OrderedField n, Transformable t) => Direction V2 n -> t -> t #

Rotate around the local origin such that the x axis aligns with the given direction.

Scaling

scalingX :: (Additive v, R1 v, Fractional n) => n -> Transformation v n #

Construct a transformation which scales by the given factor in the x (horizontal) direction.

scaleX :: (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t #

Scale a diagram by the given factor in the x (horizontal) direction. To scale uniformly, use scale.

scalingY :: (Additive v, R2 v, Fractional n) => n -> Transformation v n #

Construct a transformation which scales by the given factor in the y (vertical) direction.

scaleY :: (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t #

Scale a diagram by the given factor in the y (vertical) direction. To scale uniformly, use scale.

scaling :: (Additive v, Fractional n) => n -> Transformation v n #

Create a uniform scaling transformation.

scale :: (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a #

Scale uniformly in every dimension by the given scalar.

scaleToX :: (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t #

scaleToX w scales a diagram in the x (horizontal) direction by whatever factor required to make its width w. scaleToX should not be applied to diagrams with a width of 0, such as vrule.

scaleToY :: (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t #

scaleToY h scales a diagram in the y (vertical) direction by whatever factor required to make its height h. scaleToY should not be applied to diagrams with a height of 0, such as hrule.

scaleUToX :: (InSpace v n t, R1 v, Enveloped t, Transformable t) => n -> t -> t #

scaleUToX w scales a diagram uniformly by whatever factor required to make its width w. scaleUToX should not be applied to diagrams with a width of 0, such as vrule.

scaleUToY :: (InSpace v n t, R2 v, Enveloped t, Transformable t) => n -> t -> t #

scaleUToY h scales a diagram uniformly by whatever factor required to make its height h. scaleUToY should not be applied to diagrams with a height of 0, such as hrule.

Translation

translationX :: (Additive v, R1 v, Num n) => n -> Transformation v n #

Construct a transformation which translates by the given distance in the x (horizontal) direction.

translateX :: (InSpace v n t, R1 v, Transformable t) => n -> t -> t #

Translate a diagram by the given distance in the x (horizontal) direction.

translationY :: (Additive v, R2 v, Num n) => n -> Transformation v n #

Construct a transformation which translates by the given distance in the y (vertical) direction.

translateY :: (InSpace v n t, R2 v, Transformable t) => n -> t -> t #

Translate a diagram by the given distance in the y (vertical) direction.

translation :: v n -> Transformation v n #

Create a translation.

translate :: Transformable t => Vn t -> t -> t #

Translate by a vector.

Reflection

reflectionX :: (Additive v, R1 v, Num n) => Transformation v n #

Construct a transformation which flips a diagram from left to right, i.e. sends the point (x,y) to (-x,y).

reflectX :: (InSpace v n t, R1 v, Transformable t) => t -> t #

Flip a diagram from left to right, i.e. send the point (x,y) to (-x,y).

reflectionY :: (Additive v, R2 v, Num n) => Transformation v n #

Construct a transformation which flips a diagram from top to bottom, i.e. sends the point (x,y) to (x,-y).

reflectY :: (InSpace v n t, R2 v, Transformable t) => t -> t #

Flip a diagram from top to bottom, i.e. send the point (x,y) to (x,-y).

reflectionXY :: (Additive v, R2 v, Num n) => Transformation v n #

Construct a transformation which flips the diagram about x=y, i.e. sends the point (x,y) to (y,x).

reflectXY :: (InSpace v n t, R2 v, Transformable t) => t -> t #

Flips the diagram about x=y, i.e. send the point (x,y) to (y,x).

reflectionAbout :: OrderedField n => P2 n -> Direction V2 n -> T2 n #

reflectionAbout p d is a reflection in the line determined by the point p and direction d.

reflectAbout :: (InSpace V2 n t, OrderedField n, Transformable t) => P2 n -> Direction V2 n -> t -> t #

reflectAbout p d reflects a diagram in the line determined by the point p and direction d.

Shears

shearingX :: Num n => n -> T2 n #

shearingX d is the linear transformation which is the identity on y coordinates and sends (0,1) to (d,1).

shearX :: (InSpace V2 n t, Transformable t) => n -> t -> t #

shearX d performs a shear in the x-direction which sends (0,1) to (d,1).

shearingY :: Num n => n -> T2 n #

shearingY d is the linear transformation which is the identity on x coordinates and sends (1,0) to (1,d).

shearY :: (InSpace V2 n t, Transformable t) => n -> t -> t #

shearY d performs a shear in the y-direction which sends (1,0) to (1,d).

Deformations - non-affine transforms

parallelX0 :: (R1 v, Num n) => Deformation v v n #

The parallel projection onto the plane x=0

perspectiveX1 :: (R1 v, Functor v, Fractional n) => Deformation v v n #

The perspective division onto the plane x=1 along lines going through the origin.

parallelY0 :: (R2 v, Num n) => Deformation v v n #

The parallel projection onto the plane y=0

perspectiveY1 :: (R2 v, Functor v, Floating n) => Deformation v v n #

The perspective division onto the plane y=1 along lines going through the origin.

facingX :: (R1 v, Functor v, Fractional n) => Deformation v v n #

The viewing transform for a viewer facing along the positive X axis. X coördinates stay fixed, while Y coördinates are compressed with increasing distance. asDeformation (translation unitX) <> parallelX0 <> frustrumX = perspectiveX1

facingY :: (R2 v, Functor v, Fractional n) => Deformation v v n #

Combinators

Combining multiple diagrams

(===) :: (InSpace V2 n a, Juxtaposable a, Semigroup a) => a -> a -> a infixl 6 #

Place two diagrams (or other objects) vertically adjacent to one another, with the first diagram above the second. Since Haskell ignores whitespace in expressions, one can thus write

      c
     ===
      d
  

to place c above d. The local origin of the resulting combined diagram is the same as the local origin of the first. (===) is associative and has mempty as an identity. See the documentation of beside for more information.

(|||) :: (InSpace V2 n a, Juxtaposable a, Semigroup a) => a -> a -> a infixl 6 #

Place two diagrams (or other juxtaposable objects) horizontally adjacent to one another, with the first diagram to the left of the second. The local origin of the resulting combined diagram is the same as the local origin of the first. (|||) is associative and has mempty as an identity. See the documentation of beside for more information.

hcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a #

Lay out a list of juxtaposable objects in a row from left to right, so that their local origins lie along a single horizontal line, with successive envelopes tangent to one another.

  • For more control over the spacing, see hcat'.
  • To align the diagrams vertically (or otherwise), use alignment combinators (such as alignT or alignB) from Diagrams.TwoD.Align before applying hcat.
  • For non-axis-aligned layout, see cat.

hcat' :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => CatOpts n -> [a] -> a #

A variant of hcat taking an extra CatOpts record to control the spacing. See the cat' documentation for a description of the possibilities. For the common case of setting just a separation amount, see hsep.

hsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a #

A convenient synonym for horizontal concatenation with separation: hsep s === hcat' (with & sep .~ s).

vcat :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => [a] -> a #

Lay out a list of juxtaposable objects in a column from top to bottom, so that their local origins lie along a single vertical line, with successive envelopes tangent to one another.

  • For more control over the spacing, see vcat'.
  • To align the diagrams horizontally (or otherwise), use alignment combinators (such as alignL or alignR) from Diagrams.TwoD.Align before applying vcat.
  • For non-axis-aligned layout, see cat.

vcat' :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => CatOpts n -> [a] -> a #

A variant of vcat taking an extra CatOpts record to control the spacing. See the cat' documentation for a description of the possibilities. For the common case of setting just a separation amount, see vsep.

vsep :: (InSpace V2 n a, Floating n, Juxtaposable a, HasOrigin a, Monoid' a) => n -> [a] -> a #

A convenient synonym for vertical concatenation with separation: vsep s === vcat' (with & sep .~ s).

Spacing and envelopes

strutX :: (Metric v, R1 v, OrderedField n) => n -> QDiagram b v n m #

strutX w is an empty diagram with width w, height 0, and a centered local origin. Note that strutX (-w) behaves the same as strutX w.

strutY :: (Metric v, R2 v, OrderedField n) => n -> QDiagram b v n m #

strutY h is an empty diagram with height h, width 0, and a centered local origin. Note that strutY (-h) behaves the same as strutY h.

padX :: (Metric v, R2 v, OrderedField n, Monoid' m) => n -> QDiagram b v n m -> QDiagram b v n m #

padX s "pads" a diagram in the x-direction, expanding its envelope horizontally by a factor of s (factors between 0 and 1 can be used to shrink the envelope). Note that the envelope will expand with respect to the local origin, so if the origin is not centered horizontally the padding may appear "uneven". If this is not desired, the origin can be centered (using centerX) before applying padX.

padY :: (Metric v, R2 v, Monoid' m, OrderedField n) => n -> QDiagram b v n m -> QDiagram b v n m #

padY s "pads" a diagram in the y-direction, expanding its envelope vertically by a factor of s (factors between 0 and 1 can be used to shrink the envelope). Note that the envelope will expand with respect to the local origin, so if the origin is not centered vertically the padding may appear "uneven". If this is not desired, the origin can be centered (using centerY) before applying padY.

extrudeLeft :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m #

extrudeLeft s "extrudes" a diagram in the negative x-direction, offsetting its envelope by the provided distance. When s < 0 , the envelope is inset instead.

See the documentation for extrudeEnvelope for more information.

extrudeRight :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m #

extrudeRight s "extrudes" a diagram in the positive x-direction, offsetting its envelope by the provided distance. When s < 0 , the envelope is inset instead.

See the documentation for extrudeEnvelope for more information.

extrudeBottom :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m #

extrudeBottom s "extrudes" a diagram in the negative y-direction, offsetting its envelope by the provided distance. When s < 0 , the envelope is inset instead.

See the documentation for extrudeEnvelope for more information.

extrudeTop :: (OrderedField n, Monoid' m) => n -> QDiagram b V2 n m -> QDiagram b V2 n m #

extrudeTop s "extrudes" a diagram in the positive y-direction, offsetting its envelope by the provided distance. When s < 0 , the envelope is inset instead.

See the documentation for extrudeEnvelope for more information.

rectEnvelope :: forall b n m. (OrderedField n, Monoid' m) => Point V2 n -> V2 n -> QDiagram b V2 n m -> QDiagram b V2 n m #

rectEnvelope p v sets the envelope of a diagram to a rectangle whose lower-left corner is at p and whose upper-right corner is at p .+^ v. Useful for selecting the rectangular portion of a diagram which should actually be "viewed" in the final render, if you don't want to see the entire diagram.

Background

boundingRect :: (InSpace V2 n a, SameSpace a t, Enveloped t, Transformable t, TrailLike t, Monoid t, Enveloped a) => a -> t #

Construct a bounding rectangle for an enveloped object, that is, the smallest axis-aligned rectangle which encloses the object.

bg :: (TypeableFloat n, Renderable (Path V2 n) b) => Colour Double -> QDiagram b V2 n Any -> QDiagram b V2 n Any #

"Set the background color" of a diagram. That is, place a diagram atop a bounding rectangle of the given color.

bgFrame :: (TypeableFloat n, Renderable (Path V2 n) b) => n -> Colour Double -> QDiagram b V2 n Any -> QDiagram b V2 n Any #

Similar to bg but makes the colored background rectangle larger than the diagram. The first parameter is used to set how far the background extends beyond the diagram.

Alignment

alignL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a #

Align along the left edge, i.e. translate the diagram in a horizontal direction so that the local origin is on the left edge of the envelope.

alignR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a #

Align along the right edge.

alignT :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a #

Align along the top edge.

alignB :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a #

Align along the bottom edge.

alignTL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a #

alignTR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a #

alignBL :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a #

alignBR :: (InSpace V2 n a, Fractional n, Alignable a, HasOrigin a) => a -> a #

alignX :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a #

alignX and snugX move the local origin horizontally as follows:

  • alignX (-1) moves the local origin to the left edge of the boundary;
  • align 1 moves the local origin to the right edge;
  • any other argument interpolates linearly between these. For example, alignX 0 centers, alignX 2 moves the origin one "radius" to the right of the right edge, and so on.
  • snugX works the same way.

alignY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => n -> a -> a #

Like alignX, but moving the local origin vertically, with an argument of 1 corresponding to the top edge and (-1) corresponding to the bottom edge.

centerX :: (InSpace v n a, R1 v, Fractional n, Alignable a, HasOrigin a) => a -> a #

Center the local origin along the X-axis.

centerY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a #

Center the local origin along the Y-axis.

centerXY :: (InSpace v n a, R2 v, Fractional n, Alignable a, HasOrigin a) => a -> a #

Center along both the X- and Y-axes.

Snugging

snugL :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a #

snugR :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a #

snugT :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a #

snugB :: (InSpace V2 n a, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a #

snugX :: (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a #

See the documentation for alignX.

snugY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => n -> a -> a #

See the documentation for alignY.

snugCenterX :: (InSpace v n a, R1 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a #

snugCenterY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a #

snugCenterXY :: (InSpace v n a, R2 v, Fractional n, Alignable a, Traced a, HasOrigin a) => a -> a #

Size

Computing size

width :: (InSpace V2 n a, Enveloped a) => a -> n #

Compute the width of an enveloped object.

Note this is just diameter unitX.

height :: (InSpace V2 n a, Enveloped a) => a -> n #

Compute the height of an enveloped object.

extentX :: (InSpace v n a, R1 v, Enveloped a) => a -> Maybe (n, n) #

Compute the absolute x-coordinate range of an enveloped object in the form (lo,hi). Return Nothing for objects with an empty envelope.

Note this is just extent unitX.

extentY :: (InSpace v n a, R2 v, Enveloped a) => a -> Maybe (n, n) #

Compute the absolute y-coordinate range of an enveloped object in the form (lo,hi). Return Nothing for objects with an empty envelope.

Specifying size

mkSizeSpec2D :: Num n => Maybe n -> Maybe n -> SizeSpec V2 n #

Make a SizeSpec from possibly-specified width and height.

mkWidth :: Num n => n -> SizeSpec V2 n #

Make a SizeSpec with only width defined.

mkHeight :: Num n => n -> SizeSpec V2 n #

Make a SizeSpec with only height defined.

dims2D :: n -> n -> SizeSpec V2 n #

Make a SizeSpec from a width and height.

Textures

data Texture n #

A Texture is either a color SC, linear gradient LG, or radial gradient RG. An object can have only one texture which is determined by the Last semigroup structure.

Constructors

SC SomeColor 
LG (LGradient n) 
RG (RGradient n) 

Instances

Floating n => Transformable (Texture n) # 

Methods

transform :: Transformation (V (Texture n)) (N (Texture n)) -> Texture n -> Texture n #

type V (Texture n) # 
type V (Texture n) = V2
type N (Texture n) # 
type N (Texture n) = n

solid :: Color a => a -> Texture n #

Convert a solid colour into a texture.

data SpreadMethod #

The SpreadMethod determines what happens before lGradStart and after lGradEnd. GradPad fills the space before the start of the gradient with the color of the first stop and the color after end of the gradient with the color of the last stop. GradRepeat restarts the gradient and GradReflect restarts the gradient with the stops in reverse order.

data GradientStop d #

A gradient stop contains a color and fraction (usually between 0 and 1)

Constructors

GradientStop 

fillTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a #

_fillTexture :: (Typeable n, Floating n) => Lens' (Style V2 n) (Texture n) #

Commit a fill texture in a style. This is not a valid setter because it doesn't abide the functor law (see committed).

lineTexture :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Texture n -> a -> a #

lineTextureA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => LineTexture n -> a -> a #

stopFraction :: Lens' (GradientStop n) n #

The fraction for stop.

stopColor :: Lens' (GradientStop n) SomeColor #

A color for the stop.

mkStops :: [(Colour Double, d, Double)] -> [GradientStop d] #

A convenient function for making gradient stops from a list of triples. (An opaque color, a stop fraction, an opacity).

data LGradient n #

Linear Gradient

Instances

Fractional n => Transformable (LGradient n) # 
type V (LGradient n) # 
type V (LGradient n) = V2
type N (LGradient n) # 
type N (LGradient n) = n

_LG :: forall n. Prism' (Texture n) (LGradient n) #

lGradStops :: Lens' (LGradient n) [GradientStop n] #

A list of stops (colors and fractions).

lGradTrans :: Lens' (LGradient n) (Transformation V2 n) #

A transformation to be applied to the gradient. Usually this field will start as the identity transform and capture the transforms that are applied to the gradient.

lGradStart :: Lens' (LGradient n) (Point V2 n) #

The starting point for the first gradient stop. The coordinates are in local units and the default is (-0.5, 0).

lGradEnd :: Lens' (LGradient n) (Point V2 n) #

The ending point for the last gradient stop.The coordinates are in local units and the default is (0.5, 0).

lGradSpreadMethod :: Lens' (LGradient n) SpreadMethod #

For setting the spread method.

defaultLG :: Fractional n => Texture n #

A default is provided so that linear gradients can easily be created using lenses. For example, lg = defaultLG & lGradStart .~ (0.25 ^& 0.33). Note that no default value is provided for lGradStops, this must be set before the gradient value is used, otherwise the object will appear transparent.

mkLinearGradient :: Num n => [GradientStop n] -> Point V2 n -> Point V2 n -> SpreadMethod -> Texture n #

Make a linear gradient texture from a stop list, start point, end point, and SpreadMethod. The lGradTrans field is set to the identity transfrom, to change it use the lGradTrans lens.

data RGradient n #

Radial Gradient

Instances

Fractional n => Transformable (RGradient n) # 
type V (RGradient n) # 
type V (RGradient n) = V2
type N (RGradient n) # 
type N (RGradient n) = n

rGradStops :: Lens' (RGradient n) [GradientStop n] #

A list of stops (colors and fractions).

rGradCenter0 :: Lens' (RGradient n) (Point V2 n) #

The center point of the inner circle.

rGradRadius0 :: Lens' (RGradient n) n #

The radius of the inner cirlce in local coordinates.

rGradCenter1 :: Lens' (RGradient n) (Point V2 n) #

The center of the outer circle.

rGradRadius1 :: Lens' (RGradient n) n #

The radius of the outer circle in local coordinates.

rGradTrans :: Lens' (RGradient n) (Transformation V2 n) #

A transformation to be applied to the gradient. Usually this field will start as the identity transform and capture the transforms that are applied to the gradient.

rGradSpreadMethod :: Lens' (RGradient n) SpreadMethod #

For setting the spread method.

defaultRG :: Fractional n => Texture n #

A default is provided so that radial gradients can easily be created using lenses. For example, rg = defaultRG & rGradRadius1 .~ 0.25. Note that no default value is provided for rGradStops, this must be set before the gradient value is used, otherwise the object will appear transparent.

_RG :: forall n. Prism' (Texture n) (RGradient n) #

mkRadialGradient :: Num n => [GradientStop n] -> Point V2 n -> n -> Point V2 n -> n -> SpreadMethod -> Texture n #

Make a radial gradient texture from a stop list, radius, start point, end point, and SpreadMethod. The rGradTrans field is set to the identity transfrom, to change it use the rGradTrans lens.

Colors

fillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a #

Set the fill color. This function is polymorphic in the color type (so it can be used with either Colour or AlphaColour), but this can sometimes create problems for type inference, so the fc and fcA variants are provided with more concrete types.

_SC :: forall n. Prism' (Texture n) SomeColor #

_AC :: Prism' (Texture n) (AlphaColour Double) #

Prism onto an AlphaColour Double of a SC texture.

fc :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => Colour Double -> a -> a #

A synonym for fillColor, specialized to Colour Double (i.e. opaque colors). See comment after fillColor about backends.

fcA :: (InSpace V2 n a, Floating n, Typeable n, HasStyle a) => AlphaColour Double -> a -> a #

A synonym for fillColor, specialized to AlphaColour Double (i.e. colors with transparency). See comment after fillColor about backends.

recommendFillColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a #

Set a "recommended" fill color, to be used only if no explicit calls to fillColor (or fc, or fcA) are used. See comment after fillColor about backends.

lineColor :: (InSpace V2 n a, Color c, Typeable n, Floating n, HasStyle a) => c -> a -> a #

Set the line (stroke) color. This function is polymorphic in the color type (so it can be used with either Colour or AlphaColour), but this can sometimes create problems for type inference, so the lc and lcA variants are provided with more concrete types.

lc :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => Colour Double -> a -> a #

A synonym for lineColor, specialized to Colour Double (i.e. opaque colors). See comment in lineColor about backends.

lcA :: (InSpace V2 n a, Typeable n, Floating n, HasStyle a) => AlphaColour Double -> a -> a #

A synonym for lineColor, specialized to AlphaColour Double (i.e. colors with transparency). See comment in lineColor about backends.

Visual aids for understanding the internal model

showOrigin :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' m) => QDiagram b V2 n m -> QDiagram b V2 n m #

Mark the origin of a diagram by placing a red dot 1/50th its size.

showOrigin' :: (TypeableFloat n, Renderable (Path V2 n) b, Monoid' m) => OriginOpts n -> QDiagram b V2 n m -> QDiagram b V2 n m #

Mark the origin of a diagram, with control over colour and scale of marker dot.

data OriginOpts n #

Constructors

OriginOpts 

Fields

Instances

Fractional n => Default (OriginOpts n) # 

Methods

def :: OriginOpts n #

oColor :: forall n. Lens' (OriginOpts n) (Colour Double) #

oScale :: forall n. Lens' (OriginOpts n) n #

oMinSize :: forall n. Lens' (OriginOpts n) n #

showEnvelope :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => QDiagram b V2 n Any -> QDiagram b V2 n Any #

Mark the envelope with an approximating cubic spline using 32 points, medium line width and red line color.

showEnvelope' :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => EnvelopeOpts n -> QDiagram b V2 n Any -> QDiagram b V2 n Any #

Mark the envelope with an approximating cubic spline with control over the color, line width and number of points.

data EnvelopeOpts n #

Constructors

EnvelopeOpts 

Instances

eColor :: forall n. Lens' (EnvelopeOpts n) (Colour Double) #

eLineWidth :: forall n n. Lens (EnvelopeOpts n) (EnvelopeOpts n) (Measure n) (Measure n) #

ePoints :: forall n. Lens' (EnvelopeOpts n) Int #

showTrace :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => QDiagram b V2 n Any -> QDiagram b V2 n Any #

Mark the trace of a diagram by placing 64 red dots 1/100th its size along the trace.

showTrace' :: (Enum n, TypeableFloat n, Renderable (Path V2 n) b) => TraceOpts n -> QDiagram b V2 n Any -> QDiagram b V2 n Any #

Mark the trace of a diagram, with control over colour and scale of marker dot and the number of points on the trace.

data TraceOpts n #

Constructors

TraceOpts 

Fields

Instances

Floating n => Default (TraceOpts n) # 

Methods

def :: TraceOpts n #

tColor :: forall n. Lens' (TraceOpts n) (Colour Double) #

tScale :: forall n. Lens' (TraceOpts n) n #

tMinSize :: forall n. Lens' (TraceOpts n) n #

tPoints :: forall n. Lens' (TraceOpts n) Int #