imj-base-0.1.0.2: Game engine with geometry, easing, animated text, delta rendering.

Imj.Graphics.Text.Alignment

Contents

Description

This module exports functions and types to handle text alignemnt.

Synopsis

# Alignment

Specifies where the Text is w.r.t the reference coordinates.

Constructors

 Centered Centered on reference coordinates, favoring the RIGHT side in case of ambiguity: 1 12 123 1234 ^  RightAligned Left of the reference coordinates, including it: 1 12 123 1234 ^  LeftAligned Right of the reference coordinates, including it:1 12 123 1234 ^ 

data Alignment Source #

Constructors

 Alignment Fields_alignmentKing :: !AlignmentKindThe kind of alignment._alignmentRef :: !(Coords Pos)The reference coordinates.

Arguments

 :: Coords Pos The text will be written left of these coordinates. -> Alignment

Arguments

 :: Coords Pos The text will be centered on these coordinates. -> Alignment

# Helpers

Moves the reference coordinate one line down.

# Utilities

Arguments

 :: AlignmentKind -> Int Count of characters -> (Int, Direction)

Given a number of characters and an alignment, returns the displacement that should be done relatively to the reference coordinates in order to find the first character Coords.

For Centered, when we have an even count of characters to draw, we (somewhat arbitrarily) chose to favor the RIGHT Direction, as illustrated here where ^ indicates where the reference Coords is:

   1
12
123
1234
^


Note that this choice impacts the implementation of getSideCentersAtDistance.

Arguments

 :: Alignment -> Int number of characters to draw -> Coords Pos

Computes starting coordinates where from we should draw a series of characters of a given length, to meet the alignment constraint.