Safe Haskell | None |
---|
Collection of types.
- data ProcScript = ProcScript {}
- emptyScript :: ProcScript
- renderScript :: ProcScript -> Text
- renderFile :: FilePath -> ProcScript -> IO ()
- data ProcCode c
- data Preamble = Preamble
- data Setup = Setup
- data Draw = Draw
- data MouseClicked = MouseClicked
- data MouseReleased = MouseReleased
- data KeyPressed = KeyPressed
- class ProcType a
- data Proc_Bool
- true :: Proc_Bool
- false :: Proc_Bool
- fromBool :: Bool -> Proc_Bool
- pnot :: Proc_Bool -> Proc_Bool
- (#||) :: Proc_Bool -> Proc_Bool -> Proc_Bool
- (#&&) :: Proc_Bool -> Proc_Bool -> Proc_Bool
- data Proc_Int
- fromInt :: Int -> Proc_Int
- intToFloat :: Proc_Int -> Proc_Float
- data Proc_Float
- fromFloat :: Float -> Proc_Float
- pfloor :: Proc_Float -> Proc_Int
- pround :: Proc_Float -> Proc_Int
- data Proc_Char
- fromChar :: Char -> Proc_Char
- data Proc_Text
- fromStText :: Text -> Proc_Text
- data Proc_Image
- class Proc_Eq a where
- class Proc_Ord a where
- if_ :: ProcType a => Proc_Bool -> a -> a -> a
Processing Script
data ProcScript Source
A complete Processing script.
It consists in several parts, most of them optional.
To generate each part of the code, use the ProcM
monad
and the functions from the Graphics.Web.Processing.Interface
module. Then, run runProcM
or execProcM
to get the
code result.
More abstract functions generate ProcScript
values as well.
See modules Graphics.Web.Processing.Mid and Graphics.Web.Processing.Simple
for two alternative ways.
emptyScript :: ProcScriptSource
Empty script.
Script rendering
renderScript :: ProcScript -> TextSource
Render a script as a lazy Text
.
renderFile :: FilePath -> ProcScript -> IO ()Source
Render a script using renderScript
and
write it directly in a file.
Processing Code
A piece of Processing code. The type parameter indicates what the context of the code is. This context will allow or disallow the use of certain commands.
Contexts
The preamble is the code that is executed at the beginning of the script.
In the setup part, settings like size or frame rate are supplied.
data MouseClicked Source
Code that is executed when the mouse is clicked.
data MouseReleased Source
Code that is executed when the mouse is released.
Proc_*
types
Class of Processing value types (Proc_*
types).
Proc_*
types are types from the world of Processing.
Some of them are similar to Haskell types, like Proc_Bool
and Bool
. However, they are not equal. Proc_*
types
are instance of Eq
. However, you should instead use methods from
the analog Proc_Eq
class. Proc_*
types contain expressions instead
of values. Think of 2+2
instead of 4
. Under this situation,
2+2 /= 3+1
, since they are different expressions, even if they
evaluate to the same value. Actually, you will get True
from the evaluation of 2+2 == 3+1
, since the library is smart
enough to figure out they have the same value. But, please, don't
rely on this. Use the Proc_Eq
and Proc_Ord
classes instead.
They return Processing boolean expressions instead of Bool
values.
Anyway, the types of the library will try to force you to use Proc_*
types everywhere.
The reason this library stores expressions instead of values is that
it needs to handle things like 2+x
, where x
is an unknown value.
However, an effort is done to ensure that each expression is reduced
to its minimum extension.
Bool
Boolean values.
Int
Integer numbers.
intToFloat :: Proc_Int -> Proc_FloatSource
Cast a Proc_Int
to a Proc_Float
.
Float
data Proc_Float Source
Floating point numbers.
The provided Eq
instance checks the equality of the
internal expression, not the value.
Eq Proc_Float | |
Floating Proc_Float | WARNING: |
Fractional Proc_Float | |
Num Proc_Float | WARNING: |
Ord Proc_Float | |
Pretty Proc_Float | |
Proc_Ord Proc_Float | |
Proc_Eq Proc_Float | |
ProcType Proc_Float | |
VarLength Proc_Float | |
CustomValue Proc_Float |
fromFloat :: Float -> Proc_FloatSource
Cast a Float
value.
pfloor :: Proc_Float -> Proc_IntSource
Calculate the floor
of a Proc_Float
.
pround :: Proc_Float -> Proc_IntSource
Round a number to the closest integer.
Char
Type of characters.
Text
Type of textual values.
fromStText :: Text -> Proc_TextSource
Cast a strict Text
value.
Image
data Proc_Image Source
Type of images.
Processing classes
Eq
class for Proc_*
values.
Ord
class for Proc_*
values.