Skip to content

Interface: ICanvasContext2D โ€‹

Hierarchy โ€‹

  • CanvasCompositing

  • CanvasDrawImage

  • CanvasDrawPath

  • CanvasFillStrokeStyles

  • CanvasFilters

  • CanvasImageData

  • CanvasImageSmoothing

  • CanvasPath

  • CanvasPathDrawingStyles

  • CanvasRect

  • CanvasShadowStyles

  • CanvasState

  • CanvasText

  • CanvasTextDrawingStyles

  • CanvasTransform

  • CanvasUserInterface

    โ†ณ ICanvasContext2D

Table of contents โ€‹

Properties โ€‹

Methods โ€‹

Properties โ€‹

globalAlpha โ€‹

โ€ข globalAlpha: number

Inherited from โ€‹

CanvasCompositing.globalAlpha

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:23


globalCompositeOperation โ€‹

โ€ข globalCompositeOperation: GlobalCompositeOperation

Inherited from โ€‹

CanvasCompositing.globalCompositeOperation

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:24


fillStyle โ€‹

โ€ข fillStyle: string | CanvasGradient | CanvasPattern

Inherited from โ€‹

CanvasFillStrokeStyles.fillStyle

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:49


strokeStyle โ€‹

โ€ข strokeStyle: string | CanvasGradient | CanvasPattern

Inherited from โ€‹

CanvasFillStrokeStyles.strokeStyle

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:50


filter โ€‹

โ€ข filter: string

Inherited from โ€‹

CanvasFilters.filter

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:58


imageSmoothingEnabled โ€‹

โ€ข imageSmoothingEnabled: boolean

Inherited from โ€‹

CanvasImageSmoothing.imageSmoothingEnabled

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:83


imageSmoothingQuality โ€‹

โ€ข imageSmoothingQuality: ImageSmoothingQuality

Inherited from โ€‹

CanvasImageSmoothing.imageSmoothingQuality

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:84


lineCap โ€‹

โ€ข lineCap: CanvasLineCap

Inherited from โ€‹

CanvasPathDrawingStyles.lineCap

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:101


lineDashOffset โ€‹

โ€ข lineDashOffset: number

Inherited from โ€‹

CanvasPathDrawingStyles.lineDashOffset

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:102


lineJoin โ€‹

โ€ข lineJoin: CanvasLineJoin

Inherited from โ€‹

CanvasPathDrawingStyles.lineJoin

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:103


lineWidth โ€‹

โ€ข lineWidth: number

Inherited from โ€‹

CanvasPathDrawingStyles.lineWidth

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:104


miterLimit โ€‹

โ€ข miterLimit: number

Inherited from โ€‹

CanvasPathDrawingStyles.miterLimit

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:105


canvas โ€‹

โ€ข Readonly canvas: HTMLCanvasElement

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:138


shadowBlur โ€‹

โ€ข shadowBlur: number

Inherited from โ€‹

CanvasShadowStyles.shadowBlur

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:148


shadowColor โ€‹

โ€ข shadowColor: string

Inherited from โ€‹

CanvasShadowStyles.shadowColor

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:149


shadowOffsetX โ€‹

โ€ข shadowOffsetX: number

Inherited from โ€‹

CanvasShadowStyles.shadowOffsetX

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:150


shadowOffsetY โ€‹

โ€ข shadowOffsetY: number

Inherited from โ€‹

CanvasShadowStyles.shadowOffsetY

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:151


direction โ€‹

โ€ข direction: CanvasDirection

Inherited from โ€‹

CanvasTextDrawingStyles.direction

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:194


font โ€‹

โ€ข font: string

Inherited from โ€‹

CanvasTextDrawingStyles.font

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:195


textAlign โ€‹

โ€ข textAlign: CanvasTextAlign

Inherited from โ€‹

CanvasTextDrawingStyles.textAlign

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:196


textBaseline โ€‹

โ€ข textBaseline: CanvasTextBaseline

Inherited from โ€‹

CanvasTextDrawingStyles.textBaseline

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:197

Methods โ€‹

drawImage โ€‹

โ–ธ drawImage(image, dx, dy): void

Parameters โ€‹

NameType
imageany
dxnumber
dynumber

Returns โ€‹

void

Inherited from โ€‹

CanvasDrawImage.drawImage

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:29

โ–ธ drawImage(image, dx, dy, dw, dh): void

Parameters โ€‹

NameType
imageany
dxnumber
dynumber
dwnumber
dhnumber

Returns โ€‹

void

Inherited from โ€‹

CanvasDrawImage.drawImage

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:30

โ–ธ drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh): void

Parameters โ€‹

NameType
imageany
sxnumber
synumber
swnumber
shnumber
dxnumber
dynumber
dwnumber
dhnumber

Returns โ€‹

void

Inherited from โ€‹

CanvasDrawImage.drawImage

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:31


beginPath โ€‹

โ–ธ beginPath(): void

Returns โ€‹

void

Inherited from โ€‹

CanvasDrawPath.beginPath

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:35


clip โ€‹

โ–ธ clip(fillRule?): void

Parameters โ€‹

NameType
fillRule?IWindingRule

Returns โ€‹

void

Inherited from โ€‹

CanvasDrawPath.clip

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:36

โ–ธ clip(path, fillRule?): void

Parameters โ€‹

NameType
pathIPath2D
fillRule?IWindingRule

Returns โ€‹

void

Inherited from โ€‹

CanvasDrawPath.clip

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:37


fill โ€‹

โ–ธ fill(fillRule?): void

Parameters โ€‹

NameType
fillRule?IWindingRule

Returns โ€‹

void

Inherited from โ€‹

CanvasDrawPath.fill

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:38

โ–ธ fill(path, fillRule?): void

Parameters โ€‹

NameType
pathIPath2D
fillRule?IWindingRule

Returns โ€‹

void

Inherited from โ€‹

CanvasDrawPath.fill

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:39


isPointInPath โ€‹

โ–ธ isPointInPath(x, y, fillRule?): boolean

Parameters โ€‹

NameType
xnumber
ynumber
fillRule?IWindingRule

Returns โ€‹

boolean

Inherited from โ€‹

CanvasDrawPath.isPointInPath

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:40

โ–ธ isPointInPath(path, x, y, fillRule?): boolean

Parameters โ€‹

NameType
pathIPath2D
xnumber
ynumber
fillRule?IWindingRule

Returns โ€‹

boolean

Inherited from โ€‹

CanvasDrawPath.isPointInPath

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:41


isPointInStroke โ€‹

โ–ธ isPointInStroke(x, y): boolean

Parameters โ€‹

NameType
xnumber
ynumber

Returns โ€‹

boolean

Inherited from โ€‹

CanvasDrawPath.isPointInStroke

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:42

โ–ธ isPointInStroke(path, x, y): boolean

Parameters โ€‹

NameType
pathIPath2D
xnumber
ynumber

Returns โ€‹

boolean

Inherited from โ€‹

CanvasDrawPath.isPointInStroke

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:43


stroke โ€‹

โ–ธ stroke(): void

Returns โ€‹

void

Inherited from โ€‹

CanvasDrawPath.stroke

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:44

โ–ธ stroke(path): void

Parameters โ€‹

NameType
pathIPath2D

Returns โ€‹

void

Inherited from โ€‹

CanvasDrawPath.stroke

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:45


createConicGradient โ€‹

โ–ธ createConicGradient(startAngle, x, y): CanvasGradient

Parameters โ€‹

NameType
startAnglenumber
xnumber
ynumber

Returns โ€‹

CanvasGradient

Inherited from โ€‹

CanvasFillStrokeStyles.createConicGradient

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:51


createLinearGradient โ€‹

โ–ธ createLinearGradient(x0, y0, x1, y1): CanvasGradient

Parameters โ€‹

NameType
x0number
y0number
x1number
y1number

Returns โ€‹

CanvasGradient

Inherited from โ€‹

CanvasFillStrokeStyles.createLinearGradient

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:52


createPattern โ€‹

โ–ธ createPattern(image, repetition): CanvasPattern

Parameters โ€‹

NameType
imageany
repetitionstring

Returns โ€‹

CanvasPattern

Inherited from โ€‹

CanvasFillStrokeStyles.createPattern

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:53


createRadialGradient โ€‹

โ–ธ createRadialGradient(x0, y0, r0, x1, y1, r1): CanvasGradient

Parameters โ€‹

NameType
x0number
y0number
r0number
x1number
y1number
r1number

Returns โ€‹

CanvasGradient

Inherited from โ€‹

CanvasFillStrokeStyles.createRadialGradient

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:54


createImageData โ€‹

โ–ธ createImageData(sw, sh, settings?): ImageData

Parameters โ€‹

NameType
swnumber
shnumber
settings?ImageDataSettings

Returns โ€‹

ImageData

Inherited from โ€‹

CanvasImageData.createImageData

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:75

โ–ธ createImageData(imagedata): ImageData

Parameters โ€‹

NameType
imagedataImageData

Returns โ€‹

ImageData

Inherited from โ€‹

CanvasImageData.createImageData

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:76


getImageData โ€‹

โ–ธ getImageData(sx, sy, sw, sh, settings?): ImageData

Parameters โ€‹

NameType
sxnumber
synumber
swnumber
shnumber
settings?ImageDataSettings

Returns โ€‹

ImageData

Inherited from โ€‹

CanvasImageData.getImageData

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:77


putImageData โ€‹

โ–ธ putImageData(imagedata, dx, dy): void

Parameters โ€‹

NameType
imagedataImageData
dxnumber
dynumber

Returns โ€‹

void

Inherited from โ€‹

CanvasImageData.putImageData

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:78

โ–ธ putImageData(imagedata, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight): void

Parameters โ€‹

NameType
imagedataImageData
dxnumber
dynumber
dirtyXnumber
dirtyYnumber
dirtyWidthnumber
dirtyHeightnumber

Returns โ€‹

void

Inherited from โ€‹

CanvasImageData.putImageData

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:79


arc โ€‹

โ–ธ arc(x, y, radius, startAngle, endAngle, anticlockwise?): void

Parameters โ€‹

NameType
xnumber
ynumber
radiusnumber
startAnglenumber
endAnglenumber
anticlockwise?boolean

Returns โ€‹

void

Inherited from โ€‹

CanvasPath.arc

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:88


arcTo โ€‹

โ–ธ arcTo(x1, y1, x2, y2, radius): void

Parameters โ€‹

NameType
x1number
y1number
x2number
y2number
radiusnumber

Returns โ€‹

void

Inherited from โ€‹

CanvasPath.arcTo

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:89


bezierCurveTo โ€‹

โ–ธ bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y): void

Parameters โ€‹

NameType
cp1xnumber
cp1ynumber
cp2xnumber
cp2ynumber
xnumber
ynumber

Returns โ€‹

void

Inherited from โ€‹

CanvasPath.bezierCurveTo

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:90


closePath โ€‹

โ–ธ closePath(): void

Returns โ€‹

void

Inherited from โ€‹

CanvasPath.closePath

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:91


ellipse โ€‹

โ–ธ ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise?): void

Parameters โ€‹

NameType
xnumber
ynumber
radiusXnumber
radiusYnumber
rotationnumber
startAnglenumber
endAnglenumber
anticlockwise?boolean

Returns โ€‹

void

Inherited from โ€‹

CanvasPath.ellipse

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:92


lineTo โ€‹

โ–ธ lineTo(x, y): void

Parameters โ€‹

NameType
xnumber
ynumber

Returns โ€‹

void

Inherited from โ€‹

CanvasPath.lineTo

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:93


moveTo โ€‹

โ–ธ moveTo(x, y): void

Parameters โ€‹

NameType
xnumber
ynumber

Returns โ€‹

void

Inherited from โ€‹

CanvasPath.moveTo

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:94


quadraticCurveTo โ€‹

โ–ธ quadraticCurveTo(cpx, cpy, x, y): void

Parameters โ€‹

NameType
cpxnumber
cpynumber
xnumber
ynumber

Returns โ€‹

void

Inherited from โ€‹

CanvasPath.quadraticCurveTo

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:95


rect โ€‹

โ–ธ rect(x, y, w, h): void

Parameters โ€‹

NameType
xnumber
ynumber
wnumber
hnumber

Returns โ€‹

void

Inherited from โ€‹

CanvasPath.rect

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:96


roundRect โ€‹

โ–ธ roundRect(x, y, width, height, radius?): void

Parameters โ€‹

NameType
xnumber
ynumber
widthnumber
heightnumber
radius?number | number[]

Returns โ€‹

void

Inherited from โ€‹

CanvasPath.roundRect

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:97


getLineDash โ€‹

โ–ธ getLineDash(): number[]

Returns โ€‹

number[]

Inherited from โ€‹

CanvasPathDrawingStyles.getLineDash

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:106


setLineDash โ€‹

โ–ธ setLineDash(segments): void

Parameters โ€‹

NameType
segmentsnumber[]

Returns โ€‹

void

Inherited from โ€‹

CanvasPathDrawingStyles.setLineDash

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:107


clearRect โ€‹

โ–ธ clearRect(x, y, w, h): void

Parameters โ€‹

NameType
xnumber
ynumber
wnumber
hnumber

Returns โ€‹

void

Inherited from โ€‹

CanvasRect.clearRect

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:122


fillRect โ€‹

โ–ธ fillRect(x, y, w, h): void

Parameters โ€‹

NameType
xnumber
ynumber
wnumber
hnumber

Returns โ€‹

void

Inherited from โ€‹

CanvasRect.fillRect

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:123


strokeRect โ€‹

โ–ธ strokeRect(x, y, w, h): void

Parameters โ€‹

NameType
xnumber
ynumber
wnumber
hnumber

Returns โ€‹

void

Inherited from โ€‹

CanvasRect.strokeRect

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:124


getContextAttributes โ€‹

โ–ธ getContextAttributes(): ICanvasRenderingContext2DSettings

Returns โ€‹

ICanvasRenderingContext2DSettings

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:139


restore โ€‹

โ–ธ restore(): void

Returns โ€‹

void

Inherited from โ€‹

CanvasState.restore

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:155


save โ€‹

โ–ธ save(): void

Returns โ€‹

void

Inherited from โ€‹

CanvasState.save

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:156


drawFocusIfNeeded โ€‹

โ–ธ drawFocusIfNeeded(element): void

Parameters โ€‹

NameType
elementany

Returns โ€‹

void

Inherited from โ€‹

CanvasUserInterface.drawFocusIfNeeded

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:160

โ–ธ drawFocusIfNeeded(path, element): void

Parameters โ€‹

NameType
pathIPath2D
elementany

Returns โ€‹

void

Inherited from โ€‹

CanvasUserInterface.drawFocusIfNeeded

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:161


fillText โ€‹

โ–ธ fillText(text, x, y, maxWidth?): void

Parameters โ€‹

NameType
textstring
xnumber
ynumber
maxWidth?number

Returns โ€‹

void

Inherited from โ€‹

CanvasText.fillText

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:188


measureText โ€‹

โ–ธ measureText(text): ITextMetrics

Parameters โ€‹

NameType
textstring

Returns โ€‹

ITextMetrics

Inherited from โ€‹

CanvasText.measureText

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:189


strokeText โ€‹

โ–ธ strokeText(text, x, y, maxWidth?): void

Parameters โ€‹

NameType
textstring
xnumber
ynumber
maxWidth?number

Returns โ€‹

void

Inherited from โ€‹

CanvasText.strokeText

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:190


getTransform โ€‹

โ–ธ getTransform(): DOMMatrix

Returns โ€‹

DOMMatrix

Inherited from โ€‹

CanvasTransform.getTransform

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:201


resetTransform โ€‹

โ–ธ resetTransform(): void

Returns โ€‹

void

Inherited from โ€‹

CanvasTransform.resetTransform

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:202


rotate โ€‹

โ–ธ rotate(angle): void

Parameters โ€‹

NameType
anglenumber

Returns โ€‹

void

Inherited from โ€‹

CanvasTransform.rotate

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:203


scale โ€‹

โ–ธ scale(x, y): void

Parameters โ€‹

NameType
xnumber
ynumber

Returns โ€‹

void

Inherited from โ€‹

CanvasTransform.scale

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:204


setTransform โ€‹

โ–ธ setTransform(a, b, c, d, e, f): void

Parameters โ€‹

NameType
anumber
bnumber
cnumber
dnumber
enumber
fnumber

Returns โ€‹

void

Inherited from โ€‹

CanvasTransform.setTransform

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:205

โ–ธ setTransform(transform?): void

Parameters โ€‹

NameType
transform?DOMMatrix2DInit

Returns โ€‹

void

Inherited from โ€‹

CanvasTransform.setTransform

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:206


transform โ€‹

โ–ธ transform(a, b, c, d, e, f): void

Parameters โ€‹

NameType
anumber
bnumber
cnumber
dnumber
enumber
fnumber

Returns โ€‹

void

Inherited from โ€‹

CanvasTransform.transform

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:207


translate โ€‹

โ–ธ translate(x, y): void

Parameters โ€‹

NameType
xnumber
ynumber

Returns โ€‹

void

Inherited from โ€‹

CanvasTransform.translate

Defined in โ€‹

leafer/packages/interface/src/canvas/ICanvas.ts:208

Released under the MIT License.