Safe Haskell | None |
---|---|
Language | Haskell98 |
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 Ctx
- 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 => String -> m (Maybe Canvas)
- getCanvas :: MonadIO m => Elem -> m (Maybe Canvas)
- createCanvas :: Int -> Int -> IO Canvas
- render :: MonadIO m => Canvas -> Picture a -> m a
- renderOnTop :: 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 ()
- lineWidth :: 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 ()
- withContext :: (Ctx -> IO a) -> Picture a
Documentation
A bitmap, backed by an IMG element. JS representation is a reference to the backing IMG element.
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. JS representation is a reference to the backing canvas element.
A shape which can be either stroked or filled to yield a picture.
A picture that can be drawn onto a canvas.
A rectangle.
A color, specified using its red, green and blue components, with an optional alpha component.
A drawing context; part of a canvas. JS representation is the drawing context object itself.
data AnyImageBuffer where Source
AnyImageBuffer :: ImageBuffer a => a -> AnyImageBuffer |
class ImageBuffer a where Source
Any type that contains a buffered image which can be drawn onto a canvas.
class BitmapSource src where Source
Any type that can be used to obtain a bitmap.
loadBitmap :: MonadIO m => src -> m Bitmap Source
Load a bitmap from some kind of bitmap source.
getCanvasById :: MonadIO m => String -> 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.
render :: MonadIO m => Canvas -> Picture a -> m a Source
Clear a canvas, then draw a picture onto it.
renderOnTop :: MonadIO m => Canvas -> Picture a -> m a Source
Draw a picture onto a canvas without first clearing it.
buffer :: MonadIO m => Int -> Int -> Picture () -> m Bitmap Source
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.
lineWidth :: Double -> Picture () -> Picture () Source
Draw the given picture using a new line width.
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.
font :: String -> Picture () -> Picture () Source
Draw a picture using a certain font. Obviously only affects text.
withContext :: (Ctx -> IO a) -> Picture a Source
Perform a computation over the drawing context of the picture. This is handy for operations which are either impossible, hard or inefficient to express using the Haste.Graphics.Canvas API.