Safe Haskell | None |
---|
Variables, commands and functions. The interface to the processing.js API (http://processingjs.org/reference), with some additions, deletions and modifications.
- screenWidth :: Proc_Int
- screenHeight :: Proc_Int
- random :: ProcMonad m => Var Proc_Float -> Proc_Float -> Proc_Float -> m c ()
- noise :: (ProcMonad m, Monad (m c)) => Proc_Point -> m c Proc_Float
- class Drawing a
- data Color = Color {}
- stroke :: (ProcMonad m, Drawing c) => Color -> m c ()
- fill :: (ProcMonad m, Drawing c) => Color -> m c ()
- background :: (ProcMonad m, Drawing c) => Color -> m c ()
- strokeWeight :: (ProcMonad m, Drawing c) => Proc_Int -> m c ()
- type Proc_Point = (Proc_Float, Proc_Float)
- ellipse :: (ProcMonad m, Drawing c) => Proc_Point -> Proc_Float -> Proc_Float -> m c ()
- circle :: (ProcMonad m, Drawing c) => Proc_Point -> Proc_Float -> m c ()
- arc :: (ProcMonad m, Drawing c) => Proc_Point -> Proc_Float -> Proc_Float -> Proc_Float -> Proc_Float -> m c ()
- line :: (ProcMonad m, Drawing c) => Proc_Point -> Proc_Point -> m c ()
- point :: (ProcMonad m, Drawing c) => Proc_Point -> m c ()
- quad :: (ProcMonad m, Drawing c) => Proc_Point -> Proc_Point -> Proc_Point -> Proc_Point -> m c ()
- rect :: (ProcMonad m, Drawing c) => Proc_Point -> Proc_Float -> Proc_Float -> m c ()
- triangle :: (ProcMonad m, Drawing c) => Proc_Point -> Proc_Point -> Proc_Point -> m c ()
- bezier :: (ProcMonad m, Drawing c) => Proc_Point -> Proc_Point -> Proc_Point -> Proc_Point -> m c ()
- polygon :: (ProcMonad m, Monad (m c), Drawing c) => [Proc_Point] -> m c ()
- drawtext :: (ProcMonad m, Drawing c) => Proc_Text -> Proc_Point -> Proc_Float -> Proc_Float -> m c ()
- size :: ProcMonad m => Proc_Int -> Proc_Int -> m c ()
- setFrameRate :: ProcMonad m => Proc_Int -> m Setup ()
- translate :: (ProcMonad m, Drawing c) => Proc_Float -> Proc_Float -> m c ()
- rotate :: (ProcMonad m, Drawing c) => Proc_Float -> m c ()
- scale :: (ProcMonad m, Drawing c) => Proc_Float -> Proc_Float -> m c ()
- resetMatrix :: (ProcMonad m, Drawing c) => m c ()
- getMousePoint :: (ProcMonad m, Monad (m c)) => m c Proc_Point
- data Key
- data ArrowKey
- data KeyModifier
- data SpecialKey
- matchKey :: (ProcMonad m, Monad (m KeyPressed)) => Var Proc_Bool -> Key -> m KeyPressed ()
- ifM :: ProcMonad m => Proc_Bool -> m c a -> m c b -> m c ()
- frameCount :: (ProcMonad m, Monad (m c)) => m c Proc_Int
- getFrameRate :: (ProcMonad m, Monad (m c)) => m c Proc_Int
- comment :: ProcMonad m => Text -> m c ()
- class ProcMonad m
Predefined values
Width of the canvas.
screenHeight :: Proc_IntSource
Height of the canvas.
Commands
General
:: ProcMonad m | |
=> Var Proc_Float | Target variable. |
-> Proc_Float | Left endpoint of the interval. |
-> Proc_Float | Right endpoint of the interval. |
-> m c () |
Write a variable with a random number within an interval.
noise :: (ProcMonad m, Monad (m c)) => Proc_Point -> m c Proc_FloatSource
Noise random function.
Drawing
Class of contexts where the user can draw pictures in the screen.
Colors
RGBA colors. Values must be between 0 and 255, including in the alpha channel.
background :: (ProcMonad m, Drawing c) => Color -> m c ()Source
Fill the screen with a given color.
Stroke settings
strokeWeight :: (ProcMonad m, Drawing c) => Proc_Int -> m c ()Source
Set the weight of the lines.
Figures
type Proc_Point = (Proc_Float, Proc_Float)Source
A point as a pair of floating point numbers.
:: (ProcMonad m, Drawing c) | |
=> Proc_Point | Center of the ellipse. |
-> Proc_Float | Width of the ellipse. |
-> Proc_Float | Height of the ellipse. |
-> m c () |
Draw a ellipse.
:: (ProcMonad m, Drawing c) | |
=> Proc_Point | Center of the circle. |
-> Proc_Float | Radius. |
-> m c () |
Draw a circle.
:: (ProcMonad m, Drawing c) | |
=> Proc_Point | Center of the ellipse. |
-> Proc_Float | Width of the ellipse. |
-> Proc_Float | Height of the ellipse. |
-> Proc_Float | Initial angle (in radians). |
-> Proc_Float | End angle (in radians). |
-> m c () |
Draw an arc.
The arc is drawn following the line of an ellipse between two angles.
:: (ProcMonad m, Drawing c) | |
=> Proc_Point | Starting point. |
-> Proc_Point | End point. |
-> m c () |
Draw a line.
quad :: (ProcMonad m, Drawing c) => Proc_Point -> Proc_Point -> Proc_Point -> Proc_Point -> m c ()Source
A quad is a quadrilateral, a four sided polygon. The first parameter is the first vertex and the subsequent parameters should proceed clockwise or counter-clockwise around the defined shape.
:: (ProcMonad m, Drawing c) | |
=> Proc_Point | Location of the rectangle. |
-> Proc_Float | Width of the rectangle. |
-> Proc_Float | Height of the rectangle. |
-> m c () |
Draws a rectangle to the screen. A rectangle is a four-sided shape with every angle at ninety degrees. The first parameter set the location, the second sets the width, and the third sets the height.
triangle :: (ProcMonad m, Drawing c) => Proc_Point -> Proc_Point -> Proc_Point -> m c ()Source
A triangle is a plane created by connecting three points.
:: (ProcMonad m, Drawing c) | |
=> Proc_Point | Initial point. |
-> Proc_Point | First control point. |
-> Proc_Point | Second control point. |
-> Proc_Point | End point. |
-> m c () |
Bézier curve.
Text
:: (ProcMonad m, Drawing c) | |
=> Proc_Text | Text to draw. |
-> Proc_Point | Position. |
-> Proc_Float | Width. |
-> Proc_Float | Height. |
-> m c () |
Display a text in the screen.
The color is specified by fill
.
Setup
setFrameRate :: ProcMonad m => Proc_Int -> m Setup ()Source
Specify the number of frames to be displayed every second. The default rate is 60 frames per second.
Transformations
:: (ProcMonad m, Drawing c) | |
=> Proc_Float | Horizontal displacement. |
-> Proc_Float | Vertical displacement. |
-> m c () |
Move the current position.
rotate :: (ProcMonad m, Drawing c) => Proc_Float -> m c ()Source
Apply a rotation to the following pictures, centered at the current position.
:: (ProcMonad m, Drawing c) | |
=> Proc_Float | Horizontal scaling. |
-> Proc_Float | Vertical scaling. |
-> m c () |
Apply a scaling to the following pictures, centered at the current position.
resetMatrix :: (ProcMonad m, Drawing c) => m c ()Source
Reset the transformation matrix.
Mouse
getMousePoint :: (ProcMonad m, Monad (m c)) => m c Proc_PointSource
Get the current position of the mouse pointer.
Keyboard
Keyboard keys recognized by Processing.
matchKey :: (ProcMonad m, Monad (m KeyPressed)) => Var Proc_Bool -> Key -> m KeyPressed ()Source
Conditionals
Others
frameCount :: (ProcMonad m, Monad (m c)) => m c Proc_IntSource
Frames since the beginning of the script execution.
getFrameRate :: (ProcMonad m, Monad (m c)) => m c Proc_IntSource
Approximate number of frames per second.
comment :: ProcMonad m => Text -> m c ()Source
Include a comment in the current position of the code. You normally don't need to read the processing.js code output, but this function can be useful to analyse or debug it.
Processing monads
Types in this instance form a monad when they are applied
to a context c
. They are used to write Processing
code.
ProcMonad ProcM | When using this instance, please, be aware of the
behavior of It does not matter when the variable is read. The result will always hold the last value asigned to the variable. For example, this code v <- newVar 10 ten <- readVar v writeVar v 20 point (10,ten) will draw a point at (10,20). |
ProcMonad ScriptM | Events created inside a conditional will be automatically deleted. They must be unconditional. |
ProcMonad EventM |