nanovg-simple-0.4.0.0: Simple interface to rendering with NanoVG

Safe HaskellNone
LanguageHaskell2010

Graphics.NanoVG.Simple

Contents

Description

Module provides utilities to create usable NanoVG contexts in GLFW windows.

Synopsis

Documentation

Simple example:

import           Graphics.NanoVG.Simple
import qualified NanoVG as NVG

main :: IO ()
main = run 800 600 "Simple app" $ simpleWindow $
  NVG.circle ctx 10 10 10 *> NVG.fill ctx

Windows

data Window st Source #

Window keep state and repeatedly calls render/afterRender.

Invocation of winRender action happens inside nanovg frame, so you can use the provided context to render whatever you want. The buffers are cleared before each frame.

There is no interface to update state directly so mutable containers should be used, if so desired.

Constructors

Window 

Fields

simpleWindow :: (Context -> IO ()) -> Window () Source #

Create new window which does not need own persistent state.

run Source #

Arguments

:: Int

Initial window width.

-> Int

Initial window height.

-> String

Window title.

-> Window st

Rendering instructions to be executed in the context of the new window.

-> IO () 

Run given rendering instructions (Window structure) in new GLFW window of given size and title.

NOTE: It is currently impossible to run multiple windows simultaneously in same application.

Middlewares

type MiddleWare st0 st = Window st0 -> Window st Source #

Middleware adds some piece of functionality to existing window.

showFPS Source #

Arguments

:: Text

Alias of the font to render text with. Refer to loadFont for more

-> MiddleWare a (Data, a) 

This middleware shows FPS counter in top left corner of the window.

loadFont Source #

Arguments

:: Text

File path to load font from. Font is loaded with freetype2 so refer to it's documentation for allowed formats.

-> Text

Alias which can later be used to refer to the loaded font.

-> MiddleWare a a 

Load font from of the supported file formats and store it under given alias for further use.