Module OgamlGraphics.Text.Fx

Advanced text rendering

This module provides a more customisable way to render text through the use of iterators. This might prove more costly and also harder to use than the simple Text.t but it is much more powerful.

type t
The type of pre-rendered customised texts.

Iterators

type ('a,'b) it = 'a -> 'b -> ('b -> 'b) -> 'b
The type of an iterator. The idea behind it is that 'a is the type of objects that we manipulate (eg. Font.code ) while 'b is the type of the value computed by the iterator. We rely here on continuation passing style to deal with this vaue at each step.
type ('a,'b,'c) full_it = (('a, 'b) it * 'b * 'b -> 'c)
The type of a full iterator also containing its initial value and a post-treatment function, typically to forget information that was useful to the computation but is irrelevant as a value.
val forall : 'c -> ('a, 'c list, 'c list) full_it
This creates a simple iterator that will return a constant for each value in the iterated list.
val foreach : ('a -> 'b) -> ('a, 'b list, 'b list) full_it
Lifts a function as map would do.
val foreachi : ('a -> int -> 'b) -> ('a, ('b list * int), 'b list) full_it
Lifts a function as mapi would do: it adds a parameter counting the number of times it has been called starting at 0.
val foreachword : (Font.code list -> 'a) -> 'a -> (Font.code, ('a list * Font.code list), 'a list) full_it
This iterator is specific to Font.code and allows the user to lift a function taking words instead of characters. It splits strings on blank spaces, hence the requirement for their value as second argument.
val create : (module RenderTarget.T with type t = 'a) -> target:'a -> text:string -> position:OgamlMath.Vector2f.t -> font:Font.t -> colors:(Font.code, 'b, Color.t list) full_it -> size:int -> unit -> t
Creates a drawable text with strongly customisable parameters.
val draw : (module RenderTarget.T with type t = 'a) -> ?parameters:DrawParameter.t -> text:t -> target:'a -> unit -> unit
Draws a Fx.t.
val advance : t -> OgamlMath.Vector2f.t
The global advance of the text. Basically it is a vector such that if you add it to the position of text object, you get the position of the next character you would draw.
val boundaries : t -> OgamlMath.FloatRect.t
Returns a rectangle containing all the text.