Safe Haskell | None |
---|
Basic Canvas graphics library.
- data Bitmap
- data Canvas
- data Shape a
- data Picture a
- type Point = (Double, Double)
- type Vector = (Double, Double)
- type Angle = Double
- data Rect = Rect {}
- data Color
- data AnyImageBuffer where
- AnyImageBuffer :: ImageBuffer a => a -> AnyImageBuffer
- class ImageBuffer a where
- class BitmapSource src where
- loadBitmap :: MonadIO m => src -> m Bitmap
- getCanvasById :: MonadIO m => ElemID -> m (Maybe Canvas)
- getCanvas :: MonadIO m => Elem -> m (Maybe Canvas)
- createCanvas :: Int -> Int -> IO (Maybe Canvas)
- bitmapElem :: Bitmap -> Elem
- render :: MonadIO m => Canvas -> Picture a -> m a
- buffer :: MonadIO m => Int -> Int -> Picture () -> m Bitmap
- toDataURL :: MonadIO m => Canvas -> m URL
- setStrokeColor :: Color -> Picture ()
- setFillColor :: Color -> Picture ()
- color :: Color -> Picture () -> Picture ()
- opacity :: Double -> Picture () -> Picture ()
- translate :: Vector -> Picture () -> Picture ()
- scale :: Vector -> Picture () -> Picture ()
- rotate :: Double -> Picture () -> Picture ()
- stroke :: Shape () -> Picture ()
- fill :: Shape () -> Picture ()
- clip :: Shape () -> Picture () -> Picture ()
- line :: Point -> Point -> Shape ()
- path :: [Point] -> Shape ()
- rect :: Point -> Point -> Shape ()
- circle :: Point -> Double -> Shape ()
- arc :: Point -> Double -> Angle -> Angle -> Shape ()
- font :: String -> Picture () -> Picture ()
- text :: Point -> String -> Picture ()
Documentation
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.
A rectangle.
A color, specified using its red, green and blue components, with an optional alpha component.
data AnyImageBuffer whereSource
AnyImageBuffer :: ImageBuffer a => a -> AnyImageBuffer |
class ImageBuffer a whereSource
Any type that contains a buffered image which can be drawn onto a canvas.
class BitmapSource src whereSource
Any type that can be used to obtain a bitmap.
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.
buffer :: MonadIO m => Int -> Int -> Picture () -> m BitmapSource
Create a new off-screen buffer and store the given picture in it.
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.
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.
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.