wumpus-basic-0.16.0: Basic objects and system code built on Wumpus-Core.

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

Wumpus.Basic.Kernel.Base.QueryDC

Contents

Description

Querying the Drawing Context.

** WARNING ** - parts of this module especially the mono-space glyph metrics need a re-think and will change or be dropped.

Synopsis

Documentation

withTextAttr :: DrawingCtxM m => (RGBi -> FontAttr -> a) -> m aSource

Because textAttr is so commonly used here is a functional version that avoids tupling.

withFillAttr :: DrawingCtxM m => (RGBi -> a) -> m aSource

getRoundCornerSize :: (DrawingCtxM m, Fractional u, FromPtSize u) => m uSource

Size of the round corner factor.

getTextMargin :: (DrawingCtxM m, Fractional u, FromPtSize u) => m (u, u)Source

Get the (x,y) margin around text.

Note - not all text operations in Wumpus are drawn with text margin.

markHeight :: (DrawingCtxM m, FromPtSize u) => m uSource

The mark height is the height of a lowercase letter in the current font.

Arrowheads, dots etc. should generally be drawn at the mark height.

baselineSpacing :: (DrawingCtxM m, Fractional u) => m uSource

Vertical distance between baselines of consecutive text lines.

Glyph metrics

glyphBoundingBox :: (FromPtSize u, DrawingCtxM m) => m (BoundingBox u)Source

Get the font bounding box - this is the maximum boundary of the glyphs in the font. The span of the height is expected to be bigger than the cap_height plus descender depth.

glyphDescender :: (FromPtSize u, DrawingCtxM m) => m uSource

Note - descender is expected to be negative.

glyphVerticalSpan :: (FromPtSize u, DrawingCtxM m) => m uSource

This is the distance from cap_height to descender.

Default monospace metrics

monoLowerxHeight :: (DrawingCtxM m, FromPtSize u) => m uSource

Height of a lower case 'x' in Courier.

'x' has no ascenders or descenders.

monoTextDimensions :: (DrawingCtxM m, Num u, Ord u, FromPtSize u) => String -> m (u, u)Source

Query the dimensions of the text using the current font size but using metrics derived from Courier.

Note - the width will generally be a over-estimate for non-monospaced fonts.

monoMultiLineHeight :: (DrawingCtxM m, Fractional u, FromPtSize u) => Int -> m uSource

The heigth of n lines of text, which is n lines + n-1 line spacers

monoDefaultPadding :: (DrawingCtxM m, Fractional u, FromPtSize u) => m uSource

The default padding is half of the char width.

monoVecToCenter :: (DrawingCtxM m, Fractional u, Ord u, FromPtSize u) => String -> m (Vec2 u)Source

Vector from baseline left to center