Processing scripting, mid interface.
Unlike the basic interface (see Graphics.Web.Processing.Basic)
the script is more guided by the types. However, the output is
less predictable, since it does some tricks in order to obtain
semantics that are more coherent with Haskell. The difference is
small, but let's say that this module has more freedom writing
the output code. It also applies code optimizations, so the output
code may look different (see
How to work with it?
Everything is done within
ScriptM monad, a state monad that controls the entire script,
including the preamble, draw loop, setup, etc.
The interaction with the different parts of the script is done
via events (see
EventM). For example, the
Draw event controls the draw
mouse :: ScriptM Preamble () mouse = do on Setup $ do size screenWidth screenHeight fill $ Color 255 255 255 255 on Draw $ do background $ Color 0 0 0 255 p <- getMousePoint circle p 10
Note that to make it work, the context of the script must be
Interaction with variables is done via the
This class defines methods to interact with variables in both the
ScriptM monad and the
To store custom types in variables, see the
Once your script is complete, use
execScriptM to get the result
- module Graphics.Web.Processing.Core.Types
- class Context c
- data EventM c a
- data ScriptM c a
- on :: Context c => c -> EventM c () -> ScriptM Preamble ()
- execScriptM :: ScriptM Preamble () -> ProcScript
- data Var a
- varName :: Var a -> Text
- class ProcMonad m => ProcVarMonad m where
- module Graphics.Web.Processing.Core.Interface
Class of monads where variables can be set in a natural
way (similar to
IORef). Instances of this class behave
in a proper way, without the weird behavior of the original
Create a new variable with a starting value.
Read a variable.
Write a new value to a variable.