Portability | GHC |
---|---|
Stability | highly unstable |
Maintainer | [email protected] |
Safe Haskell | Safe-Infered |
Wumpus.Basic.Kernel.Objects.AdvObject
Description
Extended Graphic object - an AdvanceGraphic is a Graphic twinned with and advance vector.
- type AdvanceVec u = Vec2 u
- advanceH :: AdvanceVec u -> u
- advanceV :: AdvanceVec u -> u
- data AdvObject u a
- type DAdvObject a = AdvObject Double a
- type AdvGraphic u = AdvObject u (UNil u)
- type DAdvGraphic = AdvGraphic Double
- runAdvObject :: InterpretUnit u => AdvObject u a -> LocImage u a
- makeAdvObject :: InterpretUnit u => Query u (Vec2 u) -> LocImage u a -> AdvObject u a
- emptyAdvObject :: (Monoid a, InterpretUnit u) => AdvObject u a
- blankAdvObject :: (Monoid a, InterpretUnit u) => Vec2 u -> AdvObject u a
- advance :: (Monoid a, InterpretUnit u) => AdvObject u a -> AdvObject u a -> AdvObject u a
- advances :: (Monoid a, InterpretUnit u) => [AdvObject u a] -> AdvObject u a
- advspace :: (Monoid a, InterpretUnit u) => Vec2 u -> AdvObject u a -> AdvObject u a -> AdvObject u a
- evenspace :: (Monoid a, InterpretUnit u) => Vec2 u -> [AdvObject u a] -> AdvObject u a
- advrepeat :: (Monoid a, InterpretUnit u) => Int -> AdvObject u a -> AdvObject u a
- punctuate :: (Monoid a, InterpretUnit u) => AdvObject u a -> [AdvObject u a] -> AdvObject u a
- advfill :: InterpretUnit u => Vec2 u -> AdvObject u a -> AdvObject u a
Advance vector
type AdvanceVec u = Vec2 uSource
Advance vectors provide an idiom for drawing consecutive graphics. PostScript uses them to draw left-to-right text - each character has an advance vector for the width and as characters are drawn they successively displace the start point for the next character with their advance vector.
Type alias for Vec2.
advanceH :: AdvanceVec u -> uSource
Extract the horizontal component of an advance vector.
For left-to-right latin text, the vertical component of an advance vector is expected to be 0. Ingoring it seems permissible when drawing text.
advanceV :: AdvanceVec u -> uSource
Extract the verticall component of an advance vector.
Advance-vector object and graphic
Advance vector graphic - this partially models the
PostScript show
command which moves the current point by the
advance (width) vector as each character is drawn.
Instances
Monad (AdvObject u) | |
Functor (AdvObject u) | |
Applicative (AdvObject u) | |
DrawingCtxM (AdvObject u) | |
(Monoid a, InterpretUnit u) => Monoid (AdvObject u a) |
type DAdvObject a = AdvObject Double aSource
type AdvGraphic u = AdvObject u (UNil u)Source
type DAdvGraphic = AdvGraphic DoubleSource
runAdvObject :: InterpretUnit u => AdvObject u a -> LocImage u aSource
Running an AdvObject produces a LocImage.
makeAdvObject :: InterpretUnit u => Query u (Vec2 u) -> LocImage u a -> AdvObject u aSource
makeAdvObject
: loc_context_function * image -> AdvObject
Build an AdvObject
from a context function (CF
) that
generates the answer displacement vector and a LocGraphic
that draws the AdvObject
.
emptyAdvObject :: (Monoid a, InterpretUnit u) => AdvObject u aSource
emptyAdvObjectAU
: AdvObject
Build an empty AdvObject
.
The emptyAdvObject
is treated as a null primitive by
Wumpus-Core
and is not drawn, the answer vector generated is
the zero vector (V2 0 0)
.
blankAdvObject :: (Monoid a, InterpretUnit u) => Vec2 u -> AdvObject u aSource
Composition
advance :: (Monoid a, InterpretUnit u) => AdvObject u a -> AdvObject u a -> AdvObject u aSource
Draw the first AdvObject and use the advance vector to displace the second AdvObject.
The final answer is the sum of both advance vectors.
advances :: (Monoid a, InterpretUnit u) => [AdvObject u a] -> AdvObject u aSource
Concatenate the list of AdvObjects with advance
.
advspace :: (Monoid a, InterpretUnit u) => Vec2 u -> AdvObject u a -> AdvObject u a -> AdvObject u aSource
Combine the AdvObjects using the answer vector of the first object plus the separator to move the start of the second object.
evenspace :: (Monoid a, InterpretUnit u) => Vec2 u -> [AdvObject u a] -> AdvObject u aSource
List version of nextSpace
.
advrepeat :: (Monoid a, InterpretUnit u) => Int -> AdvObject u a -> AdvObject u aSource
Repeat the AdvObject n
times, moving each time with
advance
.