processing-1.0.0.0: Web graphic applications with Processing.

Safe HaskellNone

Graphics.Web.Processing.Core.Interface

Contents

Description

Variables, commands and functions. The interface to the processing.js API (http://processingjs.org/reference), with some additions, deletions and modifications.

Synopsis

Predefined values

screenWidth :: Proc_IntSource

Width of the canvas.

screenHeight :: Proc_IntSource

Height of the canvas.

Commands

General

noise :: (ProcMonad m, Monad (m c)) => Proc_Point -> m c Proc_FloatSource

Noise random function.

Drawing

class Drawing a Source

Class of contexts where the user can draw pictures in the screen. Instances:

Colors

data Color Source

RGBA colors. Values must be between 0 and 255, including in the alpha channel.

Constructors

Color 

Fields

redc :: Proc_Int

Red channel.

bluec :: Proc_Int

Blue channel.

greenc :: Proc_Int

Green channel.

alphac :: Proc_Int

Alpha channel (opacity). 0 means transparent, and 255 opaque.

stroke :: (ProcMonad m, Drawing c) => Color -> m c ()Source

Set the drawing color.

fill :: (ProcMonad m, Drawing c) => Color -> m c ()Source

Set the filling color.

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.

ellipseSource

Arguments

:: (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.

circleSource

Arguments

:: (ProcMonad m, Drawing c) 
=> Proc_Point

Center of the circle.

-> Proc_Float

Radius.

-> m c () 

Draw a circle.

arcSource

Arguments

:: (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.

lineSource

Arguments

:: (ProcMonad m, Drawing c) 
=> Proc_Point

Starting point.

-> Proc_Point

End point.

-> m c () 

Draw a line.

pointSource

Arguments

:: (ProcMonad m, Drawing c) 
=> Proc_Point

Location of the point.

-> m c () 

Prints a dot.

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.

rectSource

Arguments

:: (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.

bezierSource

Arguments

:: (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.

polygon :: (ProcMonad m, Monad (m c), Drawing c) => [Proc_Point] -> m c ()Source

Polygon drawer.

Text

drawtextSource

Arguments

:: (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

size :: ProcMonad m => Proc_Int -> Proc_Int -> m c ()Source

Set the size of the canvas.

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

translateSource

Arguments

:: (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.

scaleSource

Arguments

:: (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.

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.

Processing monads

class ProcMonad m whereSource

Types in this instance form a monad when they are applied to a context c. Then, they are used to write Processing code.

Methods

writeComment :: Text -> m c ()Source

Write a comment in the code.

iffSource

Arguments

:: Proc_Bool

Condition.

-> m c a

Execution when the condition is true.

-> m c b

Execution when the condition is false.

-> m c () 

Conditional execution.