CanvasAPI
Types
canvasDirection
typecanvasDirection=| @as("inherit")Inherit| @as("ltr")Ltr| @as("rtl")RtlcanvasFillRule
typecanvasFillRule=| @as("evenodd")Evenodd| @as("nonzero")NonzerocanvasFontKerning
typecanvasFontKerning=| @as("auto")Auto| @as("none")None| @as("normal")NormalcanvasFontStretch
typecanvasFontStretch=| @as("condensed")Condensed| @as("expanded")Expanded| @as("extra-condensed")ExtraCondensed| @as("extra-expanded")ExtraExpanded| @as("normal")Normal| @as("semi-condensed")SemiCondensed| @as("semi-expanded")SemiExpanded| @as("ultra-condensed")UltraCondensed| @as("ultra-expanded")UltraExpandedcanvasFontVariantCaps
typecanvasFontVariantCaps=| @as("all-petite-caps")AllPetiteCaps| @as("all-small-caps")AllSmallCaps| @as("normal")Normal| @as("petite-caps")PetiteCaps| @as("small-caps")SmallCaps| @as("titling-caps")TitlingCaps| @as("unicase")UnicasecanvasGradient
An opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or CanvasRenderingContext2D.createRadialGradient().See CanvasGradient on MDN
typecanvasGradient= {}Module
There are methods and helpers defined in CanvasGradient.
canvasLineCap
typecanvasLineCap=| @as("butt")Butt| @as("round")Round| @as("square")SquarecanvasLineJoin
typecanvasLineJoin=| @as("bevel")Bevel| @as("miter")Miter| @as("round")RoundcanvasPattern
An opaque object describing a pattern, based on an image, a canvas, or a video, created by the CanvasRenderingContext2D.createPattern() method.See CanvasPattern on MDN
typecanvasPattern= {}Module
There are methods and helpers defined in CanvasPattern.
canvasRenderingContext2DSettings
typecanvasRenderingContext2DSettings= {mutablealpha?:bool,mutabledesynchronized?:bool,mutablecolorSpace?:predefinedColorSpace,mutablewillReadFrequently?:bool,}Record fields
alpha
desynchronized
colorSpace
willReadFrequently
canvasTextAlign
typecanvasTextAlign=| @as("center")Center| @as("end")End| @as("left")Left| @as("right")Right| @as("start")StartcanvasTextBaseline
typecanvasTextBaseline=| @as("alphabetic")Alphabetic| @as("bottom")Bottom| @as("hanging")Hanging| @as("ideographic")Ideographic| @as("middle")Middle| @as("top")TopcanvasTextRendering
typecanvasTextRendering=| @as("auto")Auto| @as("geometricPrecision")GeometricPrecision| @as("optimizeLegibility")OptimizeLegibility| @as("optimizeSpeed")OptimizeSpeedglobalCompositeOperation
typeglobalCompositeOperation=| @as("color")Color| @as("color-burn")ColorBurn| @as("color-dodge")ColorDodge| @as("copy")Copy| @as("darken")Darken| @as("destination-atop")DestinationAtop| @as("destination-in")DestinationIn| @as("destination-out")DestinationOut| @as("destination-over")DestinationOver| @as("difference")Difference| @as("exclusion")Exclusion| @as("hard-light")HardLight| @as("hue")Hue| @as("lighten")Lighten| @as("lighter")Lighter| @as("luminosity")Luminosity| @as("multiply")Multiply| @as("overlay")Overlay| @as("saturation")Saturation| @as("screen")Screen| @as("soft-light")SoftLight| @as("source-atop")SourceAtop| @as("source-in")SourceIn| @as("source-out")SourceOut| @as("source-over")SourceOver| @as("xor")XorimageBitmap
typeimageBitmap= {width:int,height:int}Record fields
Module
There are methods and helpers defined in ImageBitmap.
imageBitmapRenderingContext
typeimageBitmapRenderingContext= {canvas:unknown}Record fields
Module
There are methods and helpers defined in ImageBitmapRenderingContext.
imageBitmapRenderingContextSettings
typeimageBitmapRenderingContextSettings= {mutablealpha?:bool,}Record fields
alpha
imageEncodeOptions
typeimageEncodeOptions= {mutabletype_?:string,mutablequality?:float,}Record fields
type_
quality
imageSmoothingQuality
typeimageSmoothingQuality=| @as("high")High| @as("low")Low| @as("medium")MediumoffscreenCanvas
typeoffscreenCanvas= {mutablewidth:int,mutableheight:int,}Record fields
width
These attributes return the dimensions of the OffscreenCanvas object's bitmap.
They can be set, to replace the bitmap with a new, transparent black bitmap of the specified dimensions (effectively resizing it).Read more on MDN
height
These attributes return the dimensions of the OffscreenCanvas object's bitmap.
They can be set, to replace the bitmap with a new, transparent black bitmap of the specified dimensions (effectively resizing it).Read more on MDN
Module
There are methods and helpers defined in OffscreenCanvas.
offscreenCanvasRenderingContext2D
typeoffscreenCanvasRenderingContext2D= {canvas:offscreenCanvas,mutableglobalAlpha:float,mutableglobalCompositeOperation:globalCompositeOperation,mutableimageSmoothingEnabled:bool,mutableimageSmoothingQuality:imageSmoothingQuality,mutablestrokeStyle:fillStyle,mutablefillStyle:fillStyle,mutableshadowOffsetX:float,mutableshadowOffsetY:float,mutableshadowBlur:float,mutableshadowColor:string,mutablefilter:string,mutablelineWidth:float,mutablelineCap:canvasLineCap,mutablelineJoin:canvasLineJoin,mutablemiterLimit:float,mutablelineDashOffset:float,mutablefont:string,mutabletextAlign:canvasTextAlign,mutabletextBaseline:canvasTextBaseline,mutabledirection:canvasDirection,mutableletterSpacing:string,mutablefontKerning:canvasFontKerning,mutablefontStretch:canvasFontStretch,mutablefontVariantCaps:canvasFontVariantCaps,mutabletextRendering:canvasTextRendering,mutablewordSpacing:string,}Record fields
offscreenRenderingContext
typeoffscreenRenderingContext=WebAPI.Prelude.anyoffscreenRenderingContextId
typeoffscreenRenderingContextId=| @as("2d")V2d| @as("bitmaprenderer")Bitmaprenderer| @as("webgl")Webgl| @as("webgl2")Webgl2| @as("webgpu")Webgpupath2D
This Canvas 2D API interface is used to declare a path that can then be used on a CanvasRenderingContext2D object. The path methods of the CanvasRenderingContext2D interface are also present on this interface, which gives you the convenience of being able to retain and replay your path whenever desired.See Path2D on MDN
typepath2D= {}Module
There are methods and helpers defined in Path2D.
predefinedColorSpace
typepredefinedColorSpace=| @as("display-p3")DisplayP3| @as("srgb")SrgbtextMetrics
The dimensions of a piece of text in the canvas, as created by the CanvasRenderingContext2D.measureText() method.See TextMetrics on MDN
typetextMetrics= {width:float,actualBoundingBoxLeft:float,actualBoundingBoxRight:float,fontBoundingBoxAscent:float,fontBoundingBoxDescent:float,actualBoundingBoxAscent:float,actualBoundingBoxDescent:float,emHeightAscent:float,emHeightDescent:float,hangingBaseline:float,alphabeticBaseline:float,ideographicBaseline:float,}Record fields
webGL2RenderingContext
typewebGL2RenderingContext= {canvas:unknown,drawingBufferWidth:float,drawingBufferHeight:float,mutabledrawingBufferColorSpace:predefinedColorSpace,mutableunpackColorSpace:predefinedColorSpace,}Record fields
webGLContextAttributes
typewebGLContextAttributes= {mutablealpha?:bool,mutabledepth?:bool,mutablestencil?:bool,mutableantialias?:bool,mutablepremultipliedAlpha?:bool,mutablepreserveDrawingBuffer?:bool,mutablepowerPreference?:webGLPowerPreference,mutablefailIfMajorPerformanceCaveat?:bool,mutabledesynchronized?:bool,}Record fields
alpha
depth
stencil
antialias
premultipliedAlpha
preserveDrawingBuffer
powerPreference
failIfMajorPerformanceCaveat
desynchronized
webGLPowerPreference
typewebGLPowerPreference=| @as("default")Default| @as("high-performance")HighPerformance| @as("low-power")LowPowerwebGLRenderingContext
Provides an interface to the OpenGL ES 2.0 graphics rendering context for the drawing surface of an HTML <canvas> element.See WebGLRenderingContext on MDN
typewebGLRenderingContext= {canvas:unknown,drawingBufferWidth:float,drawingBufferHeight:float,mutabledrawingBufferColorSpace:predefinedColorSpace,mutableunpackColorSpace:predefinedColorSpace,}