Portability | GHC |
---|---|

Stability | highly unstable |

Maintainer | stephen.tetley@gmail.com |

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
- type DAdvObject = AdvObject Double
- runAdvObject :: AdvObject u -> LocImage u (Vec2 u)
- makeAdvObject :: Query u (Vec2 u) -> LocGraphic u -> AdvObject u
- emptyAdvObject :: InterpretUnit u => AdvObject u
- blankAdvObject :: Vec2 u -> AdvObject u
- advance :: Num u => AdvObject u -> AdvObject u -> AdvObject u
- advances :: InterpretUnit u => [AdvObject u] -> AdvObject u
- advspace :: Num u => Vec2 u -> AdvObject u -> AdvObject u -> AdvObject u
- evenspace :: InterpretUnit u => Vec2 u -> [AdvObject u] -> AdvObject u
- advrepeat :: InterpretUnit u => Int -> AdvObject u -> AdvObject u
- punctuate :: InterpretUnit u => AdvObject u -> [AdvObject u] -> AdvObject u
- advfill :: Num u => Vec2 u -> AdvObject u -> AdvObject u

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

InterpretUnit u => Monoid (AdvObject u) |

type DAdvObject = AdvObject DoubleSource

runAdvObject :: AdvObject u -> LocImage u (Vec2 u)Source

makeAdvObject :: Query u (Vec2 u) -> LocGraphic u -> AdvObject uSource

`makeAdvObject`

: ` loc_context_function * graphic -> AdvObject `

Build an `AdvObject`

from a context function (`CF`

) that
generates the answer displacement vector and a `LocGraphic`

that draws the `AdvObject`

.

emptyAdvObject :: InterpretUnit u => AdvObject uSource

`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 :: Vec2 u -> AdvObject uSource

# Composition

advance :: Num u => AdvObject u -> AdvObject u -> AdvObject uSource

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 :: InterpretUnit u => [AdvObject u] -> AdvObject uSource

Concatenate the list of AdvObjects with `advance`

.

advspace :: Num u => Vec2 u -> AdvObject u -> AdvObject u -> AdvObject uSource

Combine the AdvObjects using the answer vector of the first object plus the separator to move the start of the second object.

evenspace :: InterpretUnit u => Vec2 u -> [AdvObject u] -> AdvObject uSource

List version of `nextSpace`

.

advrepeat :: InterpretUnit u => Int -> AdvObject u -> AdvObject uSource

Repeat the AdvObject `n`

times, moving each time with
`advance`

.