Copyright | (c) 2018 Schell Scivally 2023 Adrian Cochrane |
---|---|
License | MIT |
Maintainer | Schell Scivally <schell@takt.com> & Adrian Cochrane <alcinnz@argonaut-constellation.org> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module provides a method of caching rendererd text, making it suitable for interactive rendering. You can use the defaultCache or provide your own.
Synopsis
- class Layout t where
- translate :: t -> V2 Float -> t
- data AllocatedRendering t = AllocatedRendering {}
- makeDrawGlyphs :: (MonadIO m, MonadError TypograffitiError m, MonadIO n, MonadFail n, MonadError TypograffitiError n) => m (Atlas -> [(GlyphInfo, GlyphPos)] -> n (AllocatedRendering [TextTransform]))
- vertexShader :: ByteString
- fragmentShader :: ByteString
- data SpatialTransform
- = SpatialTransformTranslate (V2 Float)
- | SpatialTransformScale (V2 Float)
- | SpatialTransformRotate Float
- | SpatialTransformSkew Float
- | SpatialTransform (M44 Float)
- data TextTransform
- = TextTransformMultiply (V4 Float)
- | TextTransformSpatial SpatialTransform
- transformToUniforms :: [TextTransform] -> (M44 Float, V4 Float)
- move :: Float -> Float -> TextTransform
- scale :: Float -> Float -> TextTransform
- rotate :: Float -> TextTransform
- skew :: Float -> TextTransform
- matrix :: M44 Float -> TextTransform
- color :: Float -> Float -> Float -> Float -> TextTransform
- alpha :: Float -> TextTransform
- liftGL :: (MonadIO m, MonadError TypograffitiError m) => m (Either String a) -> m a
Documentation
Generic operations for text layout.
Instances
Layout [TextTransform] Source # | |
Defined in Typograffiti.Cache translate :: [TextTransform] -> V2 Float -> [TextTransform] Source # |
data AllocatedRendering t Source #
Holds an allocated draw function for some amount of text. The function takes one parameter that can be used to transform the text in various ways. This type is generic and can be used to take advantage of your own font rendering shaders.
makeDrawGlyphs :: (MonadIO m, MonadError TypograffitiError m, MonadIO n, MonadFail n, MonadError TypograffitiError n) => m (Atlas -> [(GlyphInfo, GlyphPos)] -> n (AllocatedRendering [TextTransform])) Source #
Constructs a callback for for computing the geometry for rendering given glyphs out of the given texture.
vertexShader :: ByteString Source #
The GPU code to finalize the position of glyphs onscreen.
fragmentShader :: ByteString Source #
The GPU code to composite the recoloured glyph into the output image.
data SpatialTransform Source #
Geometrically transform the text.
SpatialTransformTranslate (V2 Float) | Shift the text horizontally or vertically. |
SpatialTransformScale (V2 Float) | Resize the text. |
SpatialTransformRotate Float | Enlarge the text. |
SpatialTransformSkew Float | Skew the text, approximating italics (or rather obliques). |
SpatialTransform (M44 Float) | Apply an arbitrary matrix transform to the text. |
data TextTransform Source #
Modify the rendered text.
TextTransformMultiply (V4 Float) | Adjust the colour of the rendered text. |
TextTransformSpatial SpatialTransform | Adjust the position of the rendered text. |
Instances
Layout [TextTransform] Source # | |
Defined in Typograffiti.Cache translate :: [TextTransform] -> V2 Float -> [TextTransform] Source # |
transformToUniforms :: [TextTransform] -> (M44 Float, V4 Float) Source #
Convert the TextTransform
s into data that can be sent to the GPU.
move :: Float -> Float -> TextTransform Source #
Shift the text horizontally or vertically.
scale :: Float -> Float -> TextTransform Source #
Resize the text.
rotate :: Float -> TextTransform Source #
Rotate the text.
skew :: Float -> TextTransform Source #
matrix :: M44 Float -> TextTransform Source #
color :: Float -> Float -> Float -> Float -> TextTransform Source #
Recolour the text.
alpha :: Float -> TextTransform Source #
Make the text semi-transparant.
liftGL :: (MonadIO m, MonadError TypograffitiError m) => m (Either String a) -> m a Source #
Utility for calling OpenGL APIs in a error monad.