Interface OffscreenCanvasRenderingContext2D
interface OffscreenCanvasRenderingContext2D {
canvas: OffscreenCanvas;
direction: CanvasDirection;
fillStyle: string | CanvasGradient | CanvasPattern;
filter: string;
font: string;
fontKerning: CanvasFontKerning;
fontStretch: CanvasFontStretch;
fontVariantCaps: CanvasFontVariantCaps;
globalAlpha: number;
globalCompositeOperation: GlobalCompositeOperation;
imageSmoothingEnabled: boolean;
imageSmoothingQuality: ImageSmoothingQuality;
letterSpacing: string;
lineCap: CanvasLineCap;
lineDashOffset: number;
lineJoin: CanvasLineJoin;
lineWidth: number;
miterLimit: number;
shadowBlur: number;
shadowColor: string;
shadowOffsetX: number;
shadowOffsetY: number;
strokeStyle: string | CanvasGradient | CanvasPattern;
textAlign: CanvasTextAlign;
textBaseline: CanvasTextBaseline;
textRendering: CanvasTextRendering;
wordSpacing: string;
arc(
x: number,
y: number,
radius: number,
startAngle: number,
endAngle: number,
counterclockwise?: boolean,
): void;
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
beginPath(): void;
bezierCurveTo(
cp1x: number,
cp1y: number,
cp2x: number,
cp2y: number,
x: number,
y: number,
): void;
clearRect(x: number, y: number, w: number, h: number): void;
clip(fillRule?: CanvasFillRule): void;
clip(path: Path2D, fillRule?: CanvasFillRule): void;
closePath(): void;
createConicGradient(
startAngle: number,
x: number,
y: number,
): CanvasGradient;
createImageData(
sw: number,
sh: number,
settings?: ImageDataSettings,
): ImageData;
createImageData(imagedata: ImageData): ImageData;
createLinearGradient(
x0: number,
y0: number,
x1: number,
y1: number,
): CanvasGradient;
createPattern(
image: CanvasImageSourceWebCodecs,
repetition: string,
): CanvasPattern;
createRadialGradient(
x0: number,
y0: number,
r0: number,
x1: number,
y1: number,
r1: number,
): CanvasGradient;
drawImage(image: CanvasImageSourceWebCodecs, dx: number, dy: number): void;
drawImage(
image: CanvasImageSourceWebCodecs,
dx: number,
dy: number,
dw: number,
dh: number,
): void;
drawImage(
image: CanvasImageSourceWebCodecs,
sx: number,
sy: number,
sw: number,
sh: number,
dx: number,
dy: number,
dw: number,
dh: number,
): void;
ellipse(
x: number,
y: number,
radiusX: number,
radiusY: number,
rotation: number,
startAngle: number,
endAngle: number,
counterclockwise?: boolean,
): void;
fill(fillRule?: CanvasFillRule): void;
fill(path: Path2D, fillRule?: CanvasFillRule): void;
fillRect(x: number, y: number, w: number, h: number): void;
fillText(text: string, x: number, y: number, maxWidth?: number): void;
getImageData(
sx: number,
sy: number,
sw: number,
sh: number,
settings?: ImageDataSettings,
): ImageData;
getLineDash(): number[];
getTransform(): DOMMatrix;
isContextLost(): boolean;
isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean;
isPointInPath(
path: Path2D,
x: number,
y: number,
fillRule?: CanvasFillRule,
): boolean;
isPointInStroke(x: number, y: number): boolean;
isPointInStroke(path: Path2D, x: number, y: number): boolean;
lineTo(x: number, y: number): void;
measureText(text: string): TextMetrics;
moveTo(x: number, y: number): void;
putImageData(imagedata: ImageData, dx: number, dy: number): void;
putImageData(
imagedata: ImageData,
dx: number,
dy: number,
dirtyX: number,
dirtyY: number,
dirtyWidth: number,
dirtyHeight: number,
): void;
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
rect(x: number, y: number, w: number, h: number): void;
reset(): void;
resetTransform(): void;
restore(): void;
rotate(angle: number): void;
roundRect(
x: number,
y: number,
w: number,
h: number,
radii?: number | DOMPointInit | (number | DOMPointInit)[],
): void;
roundRect(
x: number,
y: number,
w: number,
h: number,
radii?: number | DOMPointInit | Iterable<number | DOMPointInit>,
): void;
save(): void;
scale(x: number, y: number): void;
setLineDash(segments: number[]): void;
setLineDash(segments: Iterable<number>): void;
setTransform(
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
): void;
setTransform(transform?: DOMMatrix2DInit): void;
stroke(): void;
stroke(path: Path2D): void;
strokeRect(x: number, y: number, w: number, h: number): void;
strokeText(text: string, x: number, y: number, maxWidth?: number): void;
transform(
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
): void;
translate(x: number, y: number): void;
}
canvas: OffscreenCanvas;
direction: CanvasDirection;
fillStyle: string | CanvasGradient | CanvasPattern;
filter: string;
font: string;
fontKerning: CanvasFontKerning;
fontStretch: CanvasFontStretch;
fontVariantCaps: CanvasFontVariantCaps;
globalAlpha: number;
globalCompositeOperation: GlobalCompositeOperation;
imageSmoothingEnabled: boolean;
imageSmoothingQuality: ImageSmoothingQuality;
letterSpacing: string;
lineCap: CanvasLineCap;
lineDashOffset: number;
lineJoin: CanvasLineJoin;
lineWidth: number;
miterLimit: number;
shadowBlur: number;
shadowColor: string;
shadowOffsetX: number;
shadowOffsetY: number;
strokeStyle: string | CanvasGradient | CanvasPattern;
textAlign: CanvasTextAlign;
textBaseline: CanvasTextBaseline;
textRendering: CanvasTextRendering;
wordSpacing: string;
arc(
x: number,
y: number,
radius: number,
startAngle: number,
endAngle: number,
counterclockwise?: boolean,
): void;
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
beginPath(): void;
bezierCurveTo(
cp1x: number,
cp1y: number,
cp2x: number,
cp2y: number,
x: number,
y: number,
): void;
clearRect(x: number, y: number, w: number, h: number): void;
clip(fillRule?: CanvasFillRule): void;
clip(path: Path2D, fillRule?: CanvasFillRule): void;
closePath(): void;
createConicGradient(
startAngle: number,
x: number,
y: number,
): CanvasGradient;
createImageData(
sw: number,
sh: number,
settings?: ImageDataSettings,
): ImageData;
createImageData(imagedata: ImageData): ImageData;
createLinearGradient(
x0: number,
y0: number,
x1: number,
y1: number,
): CanvasGradient;
createPattern(
image: CanvasImageSourceWebCodecs,
repetition: string,
): CanvasPattern;
createRadialGradient(
x0: number,
y0: number,
r0: number,
x1: number,
y1: number,
r1: number,
): CanvasGradient;
drawImage(image: CanvasImageSourceWebCodecs, dx: number, dy: number): void;
drawImage(
image: CanvasImageSourceWebCodecs,
dx: number,
dy: number,
dw: number,
dh: number,
): void;
drawImage(
image: CanvasImageSourceWebCodecs,
sx: number,
sy: number,
sw: number,
sh: number,
dx: number,
dy: number,
dw: number,
dh: number,
): void;
ellipse(
x: number,
y: number,
radiusX: number,
radiusY: number,
rotation: number,
startAngle: number,
endAngle: number,
counterclockwise?: boolean,
): void;
fill(fillRule?: CanvasFillRule): void;
fill(path: Path2D, fillRule?: CanvasFillRule): void;
fillRect(x: number, y: number, w: number, h: number): void;
fillText(text: string, x: number, y: number, maxWidth?: number): void;
getImageData(
sx: number,
sy: number,
sw: number,
sh: number,
settings?: ImageDataSettings,
): ImageData;
getLineDash(): number[];
getTransform(): DOMMatrix;
isContextLost(): boolean;
isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean;
isPointInPath(
path: Path2D,
x: number,
y: number,
fillRule?: CanvasFillRule,
): boolean;
isPointInStroke(x: number, y: number): boolean;
isPointInStroke(path: Path2D, x: number, y: number): boolean;
lineTo(x: number, y: number): void;
measureText(text: string): TextMetrics;
moveTo(x: number, y: number): void;
putImageData(imagedata: ImageData, dx: number, dy: number): void;
putImageData(
imagedata: ImageData,
dx: number,
dy: number,
dirtyX: number,
dirtyY: number,
dirtyWidth: number,
dirtyHeight: number,
): void;
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
rect(x: number, y: number, w: number, h: number): void;
reset(): void;
resetTransform(): void;
restore(): void;
rotate(angle: number): void;
roundRect(
x: number,
y: number,
w: number,
h: number,
radii?: number | DOMPointInit | (number | DOMPointInit)[],
): void;
roundRect(
x: number,
y: number,
w: number,
h: number,
radii?: number | DOMPointInit | Iterable<number | DOMPointInit>,
): void;
save(): void;
scale(x: number, y: number): void;
setLineDash(segments: number[]): void;
setLineDash(segments: Iterable<number>): void;
setTransform(
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
): void;
setTransform(transform?: DOMMatrix2DInit): void;
stroke(): void;
stroke(path: Path2D): void;
strokeRect(x: number, y: number, w: number, h: number): void;
strokeText(text: string, x: number, y: number, maxWidth?: number): void;
transform(
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
): void;
translate(x: number, y: number): void;
}
Index
Properties
canvas
direction
fillStyle
filter
font
fontKerning
fontStretch
fontVariantCaps
globalAlpha
globalCompositeOperation
imageSmoothingEnabled
imageSmoothingQuality
letterSpacing
lineCap
lineDashOffset
lineJoin
lineWidth
miterLimit
shadowBlur
shadowColor
shadowOffsetX
shadowOffsetY
strokeStyle
textAlign
textBaseline
textRendering
wordSpacing
Methods
arc
arcTo
beginPath
bezierCurveTo
clearRect
clip
closePath
createConicGradient
createImageData
createLinearGradient
createPattern
createRadialGradient
drawImage
ellipse
fill
fillRect
fillText
getImageData
getLineDash
getTransform
isContextLost
isPointInPath
isPointInStroke
lineTo
measureText
moveTo
putImageData
quadraticCurveTo
rect
reset
resetTransform
restore
rotate
roundRect
save
scale
setLineDash
setTransform
stroke
strokeRect
strokeText
transform
translate
Properties
Readonly
canvas
direction
fillStyle
filter
filter: string
font
font: string
fontKerning
fontStretch
fontVariantCaps
globalAlpha
globalAlpha: number
globalCompositeOperation
imageSmoothingEnabled
imageSmoothingEnabled: boolean
imageSmoothingQuality
letterSpacing
letterSpacing: string
lineCap
lineDashOffset
lineDashOffset: number
lineJoin
lineWidth
lineWidth: number
miterLimit
miterLimit: number
shadowBlur
shadowBlur: number
shadowColor
shadowColor: string
shadowOffsetX
shadowOffsetX: number
shadowOffsetY
shadowOffsetY: number
strokeStyle
textAlign
textBaseline
textRendering
wordSpacing
wordSpacing: string
Methods
arc
arcTo
beginPath
bezierCurveTo
clearRect
clip
- clip(fillRule?: CanvasFillRule): void
Parameters
Optional
fillRule: CanvasFillRule
Returns void
- clip(path: Path2D, fillRule?: CanvasFillRule): void
Parameters
- path: Path2D
Optional
fillRule: CanvasFillRule
Returns void
closePath
createConicGradient
- createConicGradient(startAngle: number, x: number, y: number): CanvasGradient
Parameters
- startAngle: number
- x: number
- y: number
Returns CanvasGradient
createImageData
- createImageData(sw: number, sh: number, settings?: ImageDataSettings): ImageData
Parameters
- sw: number
- sh: number
Optional
settings: ImageDataSettings
Returns ImageData
- createImageData(imagedata: ImageData): ImageData
Parameters
- imagedata: ImageData
Returns ImageData
createLinearGradient
- createLinearGradient(
x0: number,
y0: number,
x1: number,
y1: number,
): CanvasGradient Parameters
- x0: number
- y0: number
- x1: number
- y1: number
Returns CanvasGradient
createPattern
- createPattern(
image: CanvasImageSourceWebCodecs,
repetition: string,
): CanvasPattern Parameters
- image: CanvasImageSourceWebCodecs
- repetition: string
Returns CanvasPattern
createRadialGradient
- createRadialGradient(
x0: number,
y0: number,
r0: number,
x1: number,
y1: number,
r1: number,
): CanvasGradient Parameters
- x0: number
- y0: number
- r0: number
- x1: number
- y1: number
- r1: number
Returns CanvasGradient
drawImage
- drawImage(image: CanvasImageSourceWebCodecs, dx: number, dy: number): void
Parameters
- image: CanvasImageSourceWebCodecs
- dx: number
- dy: number
Returns void
- drawImage(
image: CanvasImageSourceWebCodecs,
dx: number,
dy: number,
dw: number,
dh: number,
): void Parameters
- image: CanvasImageSourceWebCodecs
- dx: number
- dy: number
- dw: number
- dh: number
Returns void
- drawImage(
image: CanvasImageSourceWebCodecs,
sx: number,
sy: number,
sw: number,
sh: number,
dx: number,
dy: number,
dw: number,
dh: number,
): void Parameters
- image: CanvasImageSourceWebCodecs
- sx: number
- sy: number
- sw: number
- sh: number
- dx: number
- dy: number
- dw: number
- dh: number
Returns void
ellipse
- ellipse(
x: number,
y: number,
radiusX: number,
radiusY: number,
rotation: number,
startAngle: number,
endAngle: number,
counterclockwise?: boolean,
): void Parameters
- x: number
- y: number
- radiusX: number
- radiusY: number
- rotation: number
- startAngle: number
- endAngle: number
Optional
counterclockwise: boolean
Returns void
fill
- fill(fillRule?: CanvasFillRule): void
Parameters
Optional
fillRule: CanvasFillRule
Returns void
- fill(path: Path2D, fillRule?: CanvasFillRule): void
Parameters
- path: Path2D
Optional
fillRule: CanvasFillRule
Returns void
fillRect
fillText
getImageData
- getImageData(
sx: number,
sy: number,
sw: number,
sh: number,
settings?: ImageDataSettings,
): ImageData Parameters
- sx: number
- sy: number
- sw: number
- sh: number
Optional
settings: ImageDataSettings
Returns ImageData
getLineDash
getTransform
isContextLost
isPointInPath
- isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean
Parameters
- x: number
- y: number
Optional
fillRule: CanvasFillRule
Returns boolean
- isPointInPath(
path: Path2D,
x: number,
y: number,
fillRule?: CanvasFillRule,
): boolean Parameters
- path: Path2D
- x: number
- y: number
Optional
fillRule: CanvasFillRule
Returns boolean
isPointInStroke
lineTo
measureText
- measureText(text: string): TextMetrics
Parameters
- text: string
Returns TextMetrics
moveTo
putImageData
- putImageData(imagedata: ImageData, dx: number, dy: number): void
Parameters
- imagedata: ImageData
- dx: number
- dy: number
Returns void
- putImageData(
imagedata: ImageData,
dx: number,
dy: number,
dirtyX: number,
dirtyY: number,
dirtyWidth: number,
dirtyHeight: number,
): void Parameters
- imagedata: ImageData
- dx: number
- dy: number
- dirtyX: number
- dirtyY: number
- dirtyWidth: number
- dirtyHeight: number
Returns void
quadraticCurveTo
rect
reset
resetTransform
restore
rotate
roundRect
- roundRect(
x: number,
y: number,
w: number,
h: number,
radii?: number | DOMPointInit | (number | DOMPointInit)[],
): void Parameters
- x: number
- y: number
- w: number
- h: number
Optional
radii: number | DOMPointInit | (number | DOMPointInit)[]
Returns void
- roundRect(
x: number,
y: number,
w: number,
h: number,
radii?: number | DOMPointInit | Iterable<number | DOMPointInit>,
): void Parameters
- x: number
- y: number
- w: number
- h: number
Optional
radii: number | DOMPointInit | Iterable<number | DOMPointInit>
Returns void
save
scale
setLineDash
setTransform
- setTransform(
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
): void Parameters
- a: number
- b: number
- c: number
- d: number
- e: number
- f: number
Returns void
- setTransform(transform?: DOMMatrix2DInit): void
Parameters
Optional
transform: DOMMatrix2DInit
Returns void
MDN Reference