# class CanvasRenderingContext2D

#### package js.html

Available on HTML5

To get an object of this interface, call `getContext()` on a `canvas element`, supplying "2d" as the argument:

Documentation CanvasRenderingContext2D by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D

### Variables

###

`read onlycanvas:CanvasElement`

###

`fillStyle:EitherType<String, EitherType<CanvasGradient, CanvasPattern>>`

###

`filter:String`

###

`font:String`

###

`globalAlpha:Float`

###

`globalCompositeOperation:String`

###

`imageSmoothingEnabled:Bool`

###

`lineCap:String`

###

`lineDashOffset:Float`

###

`lineJoin:String`

###

`lineWidth:Float`

###

`miterLimit:Float`

###

`shadowBlur:Float`

###

`shadowColor:String`

###

`shadowOffsetX:Float`

###

`shadowOffsetY:Float`

###

`strokeStyle:EitherType<String, EitherType<CanvasGradient, CanvasPattern>>`

###

`textAlign:String`

###

`textBaseline:String`

### Methods

###

`addHitRegion (?options:HitRegionOptions):Void`

Throws:

`null` | DOMError

###

`arc (x:Float, y:Float, radius:Float, startAngle:Float, endAngle:Float, anticlockwise:Bool = false):Void`

Throws:

`null` | DOMError

###

`arcTo (x1:Float, y1:Float, x2:Float, y2:Float, radius:Float):Void`

Throws:

`null` | DOMError

###

`beginPath ():Void`

###

`bezierCurveTo (cp1x:Float, cp1y:Float, cp2x:Float, cp2y:Float, x:Float, y:Float):Void`

###

`clearHitRegions ():Void`

###

`clearRect (x:Float, y:Float, w:Float, h:Float):Void`

###

`clip (path:Path2D, winding:CanvasWindingRule = "nonzero"):Void`

`clip (winding:CanvasWindingRule = "nonzero"):Void`

###

`closePath ():Void`

###

`createImageData (imagedata:ImageData):ImageData`

`createImageData (sw:Float, sh:Float):ImageData`

Throws:

`null` | DOMError

###

`createLinearGradient (x0:Float, y0:Float, x1:Float, y1:Float):CanvasGradient`

###

`createPattern (image:EitherType<ImageElement, EitherType<CanvasElement, EitherType<VideoElement, ImageBitmap>>>, repetition:String):CanvasPattern`

Throws:

`null` | DOMError

###

`createRadialGradient (x0:Float, y0:Float, r0:Float, x1:Float, y1:Float, r1:Float):CanvasGradient`

Throws:

`null` | DOMError

###

`drawCustomFocusRing (element:Element):Bool`

###

`drawFocusIfNeeded (element:Element):Void`

Throws:

`null` | DOMError

###

`drawImage (image:EitherType<ImageElement, EitherType<CanvasElement, EitherType<VideoElement, ImageBitmap>>>, sx:Float, sy:Float, sw:Float, sh:Float, dx:Float, dy:Float, dw:Float, dh:Float):Void`

`drawImage (image:EitherType<ImageElement, EitherType<CanvasElement, EitherType<VideoElement, ImageBitmap>>>, dx:Float, dy:Float):Void`

`drawImage (image:EitherType<ImageElement, EitherType<CanvasElement, EitherType<VideoElement, ImageBitmap>>>, dx:Float, dy:Float, dw:Float, dh:Float):Void`

Throws:

`null` | DOMError

###

`ellipse (x:Float, y:Float, radiusX:Float, radiusY:Float, rotation:Float, startAngle:Float, endAngle:Float, anticlockwise:Bool = false):Void`

Throws:

`null` | DOMError

###

`fill (path:Path2D, winding:CanvasWindingRule = "nonzero"):Void`

`fill (winding:CanvasWindingRule = "nonzero"):Void`

###

`fillRect (x:Float, y:Float, w:Float, h:Float):Void`

###

`fillText (text:String, x:Float, y:Float, ?maxWidth:Float):Void`

Throws:

`null` | DOMError

###

`getImageData (sx:Float, sy:Float, sw:Float, sh:Float):ImageData`

Throws:

`null` | DOMError

###

`getLineDash ():Array<Float>`

###

`isPointInPath (path:Path2D, x:Float, y:Float, winding:CanvasWindingRule = "nonzero"):Bool`

`isPointInPath (x:Float, y:Float, winding:CanvasWindingRule = "nonzero"):Bool`

###

`isPointInStroke (path:Path2D, x:Float, y:Float):Bool`

`isPointInStroke (x:Float, y:Float):Bool`

###

`lineTo (x:Float, y:Float):Void`

###

`measureText (text:String):TextMetrics`

Throws:

`null` | DOMError

###

`moveTo (x:Float, y:Float):Void`

###

`putImageData (imagedata:ImageData, dx:Float, dy:Float, dirtyX:Float, dirtyY:Float, dirtyWidth:Float, dirtyHeight:Float):Void`

`putImageData (imagedata:ImageData, dx:Float, dy:Float):Void`

Throws:

`null` | DOMError

###

`quadraticCurveTo (cpx:Float, cpy:Float, x:Float, y:Float):Void`

###

`rect (x:Float, y:Float, w:Float, h:Float):Void`

###

`removeHitRegion (id:String):Void`

###

`resetTransform ():Void`

Throws:

`null` | DOMError

###

`restore ():Void`

###

`rotate (angle:Float):Void`

Throws:

`null` | DOMError

###

`save ():Void`

###

`scale (x:Float, y:Float):Void`

Throws:

`null` | DOMError

###

`setLineDash (segments:Array<Float>):Void`

Throws:

`null` | DOMError

###

`setTransform (a:Float, b:Float, c:Float, d:Float, e:Float, f:Float):Void`

Throws:

`null` | DOMError

###

`stroke (path:Path2D):Void`

`stroke ():Void`

###

`strokeRect (x:Float, y:Float, w:Float, h:Float):Void`

###

`strokeText (text:String, x:Float, y:Float, ?maxWidth:Float):Void`

Throws:

`null` | DOMError

###

`transform (a:Float, b:Float, c:Float, d:Float, e:Float, f:Float):Void`

Throws:

`null` | DOMError

###

`translate (x:Float, y:Float):Void`

Throws:

`null` | DOMError