generative-art-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Draw.Text

Synopsis

Documentation

showTextAligned Source #

Arguments

:: CairoString string 
=> HAlign

Horizontal alignment

-> VAlign

Vertical alignment

-> string

Text

-> Render () 

Like Cairo’s showText, but with alignment parameters. Since Cairo’s text API is pretty wonky, you may have to sprinkle this with moveTo/moveToVec or newPath.

(image code)

Expand
>>> :{
haddockRender "Draw/Text/show_text_aligned.svg" 200 30 $ \_ -> do
    coordinateSystem CairoStandard_ZeroTopLeft_XRight_YDown
    C.moveTo (200/2) (30/2)
    C.scale 3 3
    showTextAligned HCenter VCenter "Hello world!"
:}
Generated file: size 8KB, crc32: 0xefcaecf4

plotText :: PlotTextOptions -> String -> [Polyline] Source #

Some text as pure geometry.

(image code)

Expand
>>> :{
haddockRender "Draw/Text/plot_text.svg" 200 30 $ \_ -> do
    let opts = PlotTextOptions
            { _textStartingPoint = Vec2 (200/2) (30/2)
            , _textHeight = 20
            , _textHAlign = HCenter
            , _textVAlign = VCenter }
        glyphs = plotText opts "Hello world!"
    for_ glyphs $ \glyph -> sketch glyph >> stroke
:}
Generated file: size 7KB, crc32: 0xd253d9dd

data PlotTextOptions Source #

Constructors

PlotTextOptions 

Fields

Instances

Instances details
Default PlotTextOptions Source # 
Instance details

Defined in Draw.Text

data HAlign Source #

Horizontal alignment

Constructors

HLeft 
HCenter 
HRight 

Instances

Instances details
Show HAlign Source # 
Instance details

Defined in Draw.Text

Eq HAlign Source # 
Instance details

Defined in Draw.Text

Methods

(==) :: HAlign -> HAlign -> Bool #

(/=) :: HAlign -> HAlign -> Bool #

Ord HAlign Source # 
Instance details

Defined in Draw.Text

data VAlign Source #

Vertical alignment

Constructors

VTop 
VCenter 
VBottom 

Instances

Instances details
Show VAlign Source # 
Instance details

Defined in Draw.Text

Eq VAlign Source # 
Instance details

Defined in Draw.Text

Methods

(==) :: VAlign -> VAlign -> Bool #

(/=) :: VAlign -> VAlign -> Bool #

Ord VAlign Source # 
Instance details

Defined in Draw.Text