| Copyright | (C) 2016-2026 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <code@dmj.io> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Canvas.FFI
Description
One JavaScript import per straight-line CanvasRenderingContext2D
operation: a method call or a property assignment that returns nothing.
Miso.Canvas used to go through the generic # and setField:
a method name marshalled to a JavaScript string, a property lookup, an
argument array, and a JSVal handle for every argument and the result,
on each operation. A direct import does one call with the numbers as
numbers. On MicroHs this made the canvas benchmark in sample-app-canvas
about 3.5 times faster (78 to 22 ms per frame for 1000 rectangles).
fillStyleRGB, strokeStyleRGB, shadowColorRGB and their RGBA
variants take the colour as numbers and build the rgb(…) string in
JavaScript, instead of renderColor building it from
Haskell (several string operations across the FFI per colour).
Operations that return a value (gradients, patterns, image data) stay on the generic path in Miso.Canvas. The native GHC backend has no JavaScript FFI, so there these are the generic calls as before.
Synopsis
- jsString :: MisoString -> MisoString
- clearRect :: JSVal -> Double -> Double -> Double -> Double -> IO ()
- fillRect :: JSVal -> Double -> Double -> Double -> Double -> IO ()
- strokeRect :: JSVal -> Double -> Double -> Double -> Double -> IO ()
- rect :: JSVal -> Double -> Double -> Double -> Double -> IO ()
- quadraticCurveTo :: JSVal -> Double -> Double -> Double -> Double -> IO ()
- beginPath :: JSVal -> IO ()
- closePath :: JSVal -> IO ()
- fill :: JSVal -> IO ()
- stroke :: JSVal -> IO ()
- clip :: JSVal -> IO ()
- save :: JSVal -> IO ()
- restore :: JSVal -> IO ()
- moveTo :: JSVal -> Double -> Double -> IO ()
- lineTo :: JSVal -> Double -> Double -> IO ()
- scale :: JSVal -> Double -> Double -> IO ()
- translate :: JSVal -> Double -> Double -> IO ()
- rotate :: JSVal -> Double -> IO ()
- bezierCurveTo :: JSVal -> Double -> Double -> Double -> Double -> Double -> Double -> IO ()
- transform :: JSVal -> Double -> Double -> Double -> Double -> Double -> Double -> IO ()
- setTransform :: JSVal -> Double -> Double -> Double -> Double -> Double -> Double -> IO ()
- arc :: JSVal -> Double -> Double -> Double -> Double -> Double -> IO ()
- arcTo :: JSVal -> Double -> Double -> Double -> Double -> Double -> IO ()
- fillText :: JSVal -> MisoString -> Double -> Double -> IO ()
- strokeText :: JSVal -> MisoString -> Double -> Double -> IO ()
- drawImage :: JSVal -> JSVal -> Double -> Double -> IO ()
- drawImage4 :: JSVal -> JSVal -> Double -> Double -> Double -> Double -> IO ()
- putImageData :: JSVal -> JSVal -> Double -> Double -> IO ()
- lineWidth :: JSVal -> Double -> IO ()
- miterLimit :: JSVal -> Double -> IO ()
- shadowBlur :: JSVal -> Double -> IO ()
- shadowOffsetX :: JSVal -> Double -> IO ()
- shadowOffsetY :: JSVal -> Double -> IO ()
- globalAlpha :: JSVal -> Double -> IO ()
- font :: JSVal -> MisoString -> IO ()
- lineCap :: JSVal -> MisoString -> IO ()
- lineJoin :: JSVal -> MisoString -> IO ()
- direction :: JSVal -> MisoString -> IO ()
- textAlign :: JSVal -> MisoString -> IO ()
- textBaseline :: JSVal -> MisoString -> IO ()
- globalCompositeOperation :: JSVal -> MisoString -> IO ()
- shadowColor :: JSVal -> MisoString -> IO ()
- fillStyle :: JSVal -> JSVal -> IO ()
- strokeStyle :: JSVal -> JSVal -> IO ()
- fillStyleRGB :: JSVal -> Int -> Int -> Int -> IO ()
- fillStyleRGBA :: JSVal -> Int -> Int -> Int -> Double -> IO ()
- strokeStyleRGB :: JSVal -> Int -> Int -> Int -> IO ()
- strokeStyleRGBA :: JSVal -> Int -> Int -> Int -> Double -> IO ()
- shadowColorRGB :: JSVal -> Int -> Int -> Int -> IO ()
- shadowColorRGBA :: JSVal -> Int -> Int -> Int -> Double -> IO ()
Documentation
jsString :: MisoString -> MisoString Source #
A MisoString as the string the imports take.
bezierCurveTo :: JSVal -> Double -> Double -> Double -> Double -> Double -> Double -> IO () Source #
strokeText :: JSVal -> MisoString -> Double -> Double -> IO () Source #
textBaseline :: JSVal -> MisoString -> IO () Source #
globalCompositeOperation :: JSVal -> MisoString -> IO () Source #
shadowColor :: JSVal -> MisoString -> IO () Source #