haste-compiler-0.2.99: Haskell To ECMAScript compiler

Safe HaskellNone

Haste.Graphics.Canvas

Description

Basic Canvas graphics library.

Synopsis

Documentation

data Canvas Source

A canvas; a viewport into which a picture can be rendered. The origin of the coordinate system used by the canvas is the top left corner of the canvas element.

Instances

data Shape a Source

A shape which can be either stroked or filled to yield a picture.

Instances

data Picture a Source

A picture that can be drawn onto a canvas.

Instances

type Point = (Double, Double)Source

A point in the plane.

type Vector = (Double, Double)Source

A two dimensional vector.

type Angle = DoubleSource

An angle, given in radians.

data Rect Source

A rectangle.

Constructors

Rect 

data Color Source

A color, specified using its red, green and blue components, with an optional alpha component.

Constructors

RGB Int Int Int 
RGBA Int Int Int Double 

class ImageBuffer a whereSource

Any type that contains a buffered image which can be drawn onto a canvas.

Methods

draw :: a -> Point -> Picture ()Source

Draw the image buffer with its top left corner at the specified point.

drawClipped :: a -> Point -> Rect -> Picture ()Source

Draw a portion of the image buffer with its top left corner at the specified point.

class BitmapSource src whereSource

Any type that can be used to obtain a bitmap.

Methods

loadBitmap :: MonadIO m => src -> m BitmapSource

Load a bitmap from some kind of bitmap source.

getCanvasById :: MonadIO m => ElemID -> m (Maybe Canvas)Source

Create a 2D drawing context from a DOM element identified by its ID.

getCanvas :: MonadIO m => Elem -> m (Maybe Canvas)Source

Create a 2D drawing context from a DOM element.

createCanvas :: Int -> Int -> IO (Maybe Canvas)Source

Create an off-screen buffer of the specified size.

bitmapElem :: Bitmap -> ElemSource

Get the HTML element associated with the given bitmap.

render :: MonadIO m => Canvas -> Picture a -> m aSource

Clear a canvas, then draw a picture onto it.

buffer :: MonadIO m => Int -> Int -> Picture () -> m BitmapSource

Create a new off-screen buffer and store the given picture in it.

toDataURL :: MonadIO m => Canvas -> m URLSource

Generate a data URL from the contents of a canvas.

setStrokeColor :: Color -> Picture ()Source

Set a new color for strokes.

setFillColor :: Color -> Picture ()Source

Set a new fill color.

color :: Color -> Picture () -> Picture ()Source

Draw the given Picture using the specified Color for both stroke and fill, then restore the previous stroke and fill colors.

opacity :: Double -> Picture () -> Picture ()Source

Draw a picture with the given opacity.

translate :: Vector -> Picture () -> Picture ()Source

Draw the specified picture using the given point as the origin.

scale :: Vector -> Picture () -> Picture ()Source

Draw the specified picture scaled as specified by the scale vector.

rotate :: Double -> Picture () -> Picture ()Source

Draw the specified picture rotated r radians clockwise.

stroke :: Shape () -> Picture ()Source

Draw the contours of a shape.

fill :: Shape () -> Picture ()Source

Draw a filled shape.

clip :: Shape () -> Picture () -> Picture ()Source

Draw a picture clipped to the given path.

line :: Point -> Point -> Shape ()Source

Draw a line between two points.

path :: [Point] -> Shape ()Source

Draw a path along the specified points.

rect :: Point -> Point -> Shape ()Source

Draw a rectangle between the two given points.

circle :: Point -> Double -> Shape ()Source

Draw a circle shape.

arc :: Point -> Double -> Angle -> Angle -> Shape ()Source

Draw an arc. An arc is specified as a drawn portion of an imaginary circle with a center point, a radius, a starting angle and an ending angle. For instance, arc (0, 0) 10 0 pi will draw a half circle centered at (0, 0), with a radius of 10 pixels.

font :: String -> Picture () -> Picture ()Source

Draw a picture using a certain font. Obviously only affects text.

text :: Point -> String -> Picture ()Source

Draw some text onto the canvas.