Graphics.Canvas
- Package
- purescript-canvas
- Repository
- paf31/purescript-canvas
This module defines foreign types and functions for working with the 2D Canvas API.
#CanvasElement Source
data CanvasElement :: TypeA canvas HTML element.
#CanvasImageSource Source
data CanvasImageSource :: TypeOpaque object for drawing elements and things to the canvas.
#CanvasPattern Source
data CanvasPattern :: TypeOpaque object describing a pattern.
#CanvasGradient Source
data CanvasGradient :: TypeOpaque object describing a gradient.
#tryLoadImage Source
tryLoadImage :: forall eff. String -> (Maybe CanvasImageSource -> Eff (canvas :: CANVAS | eff) Unit) -> Eff (canvas :: CANVAS | eff) UnitAsynchronously load an image file by specifying its path.
#getCanvasElementById Source
getCanvasElementById :: forall eff. String -> Eff (canvas :: CANVAS | eff) (Maybe CanvasElement)Get a canvas element by ID, or Nothing if the element does not exist.
#getContext2D Source
getContext2D :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) Context2DGet the 2D graphics context for a canvas element.
#getCanvasWidth Source
getCanvasWidth :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) NumberGet the canvas width in pixels.
#getCanvasHeight Source
getCanvasHeight :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) NumberGet the canvas height in pixels.
#setCanvasWidth Source
setCanvasWidth :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) CanvasElementSet the canvas width in pixels.
#setCanvasHeight Source
setCanvasHeight :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) CanvasElementSet the canvas height in pixels.
#Dimensions Source
type Dimensions = { height :: Number, width :: Number }Canvas dimensions (width and height) in pixels.
#getCanvasDimensions Source
getCanvasDimensions :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) DimensionsGet the canvas dimensions in pixels.
#setCanvasDimensions Source
setCanvasDimensions :: forall eff. Dimensions -> CanvasElement -> Eff (canvas :: CANVAS | eff) CanvasElementSet the canvas dimensions in pixels.
#canvasToDataURL Source
canvasToDataURL :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) StringCreate a data URL for the current canvas contents
#Composite Source
data CompositeEnumerates the different types of composite operations and blend modes.
Constructors
SourceOverSourceInSourceOutSourceAtopDestinationOverDestinationInDestinationOutDestinationAtopLighterCopyXorMultiplyScreenOverlayDarkenLightenColorDodgeColorBurnHardLightSoftLightDifferenceExclusionHueSaturationColorLuminosity
Instances
#ScaleTransform Source
type ScaleTransform = { scaleX :: Number, scaleY :: Number }An object representing a scaling transform:
- The scale factors in the
xandydirections,scaleXandscaleY.
#TranslateTransform Source
type TranslateTransform = { translateX :: Number, translateY :: Number }An object representing a translation:
- The translation amounts in the
xandydirections,translateXandtranslateY.
#measureText Source
measureText :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) TextMetricsMeasure some text.
#imageDataWidth Source
imageDataWidth :: ImageData -> IntGet the width of an ImageData object.
#imageDataHeight Source
imageDataHeight :: ImageData -> IntGet the height of an ImageData object.
#imageDataBuffer Source
imageDataBuffer :: ImageData -> Uint8ClampedArrayGet the underlying buffer from an ImageData object.
#drawImageScale Source
drawImageScale :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D#PatternRepeat Source
#createPattern Source
createPattern :: forall eff. CanvasImageSource -> PatternRepeat -> Context2D -> Eff (canvas :: CANVAS | eff) CanvasPatternCreate a new canvas pattern (repeatable image).
#setPatternFillStyle Source
setPatternFillStyle :: forall eff. CanvasPattern -> Context2D -> Eff (canvas :: CANVAS | eff) Context2DSet the Context2D fillstyle to the CanvasPattern.
#LinearGradient Source
type LinearGradient = { x0 :: Number, x1 :: Number, y0 :: Number, y1 :: Number }A type representing a linear gradient.
- Starting point coordinates: (
x0,y0) - Ending point coordinates: (
x1,y1)
#createLinearGradient Source
createLinearGradient :: forall eff. LinearGradient -> Context2D -> Eff (canvas :: CANVAS | eff) CanvasGradientCreate a linear CanvasGradient.
#createRadialGradient Source
createRadialGradient :: forall eff. RadialGradient -> Context2D -> Eff (canvas :: CANVAS | eff) CanvasGradientCreate a radial CanvasGradient.
#addColorStop Source
addColorStop :: forall eff. Number -> String -> CanvasGradient -> Eff (canvas :: CANVAS | eff) CanvasGradientAdd a single color stop to a CanvasGradient.
#setGradientFillStyle Source
setGradientFillStyle :: forall eff. CanvasGradient -> Context2D -> Eff (canvas :: CANVAS | eff) Context2DSet the Context2D fillstyle to the CanvasGradient.
#QuadraticCurve Source
type QuadraticCurve = { cpx :: Number, cpy :: Number, x :: Number, y :: Number }A type representing a quadratic Bézier curve.
- Bézier control point: (
cpx,cpy) - Ending point coordinates: (
x,y)
#quadraticCurveTo Source
quadraticCurveTo :: forall eff. QuadraticCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Context2DDraw a quadratic Bézier curve.
#bezierCurveTo Source
bezierCurveTo :: forall eff. BezierCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Context2DDraw a cubic Bézier curve.
- Modules
- Graphics.
Canvas