Safe Haskell | None |
---|
Graphics.Web.Processing.Core.Types
Contents
Description
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
- 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.
-
Preamble
: Usually the place where variables are initialized. -
Setup
: After running the code in the preamble, the code in this part is executed once. -
Draw
: After the setup, this part of the code is executed in loops over and over again. -
MouseClicked
: Each time the user clicks, the code here is executed once.
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.
Constructors
ProcScript | |
Fields |
Instances
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.
Constructors
Preamble |
In the setup part, settings like size or frame rate are supplied.
Constructors
Setup |
data MouseClicked Source
Code that is executed when the mouse is clicked.
Constructors
MouseClicked |
Instances
data MouseReleased Source
Code that is executed when the mouse is released.
Constructors
MouseReleased |
Instances
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
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 are 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.
Instances
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
Calculates the floor
of a Proc_Float
.
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.
Methods
(#<=) :: a -> a -> Proc_BoolSource
(#<) :: a -> a -> Proc_BoolSource
Instances