// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://html.spec.whatwg.org/C/#the-offscreen-2d-rendering-context
[
ActiveScriptWrappable,
Exposed=(Window,Worker)
] interface OffscreenCanvasRenderingContext2D {
// back-reference to the canvas
[ImplementedAs=offscreenCanvasForBinding] readonly attribute OffscreenCanvas canvas;
// state
void save(); // push state on state stack
[NoAllocDirectCall, RaisesException] void restore(); // pop state stack if top state was pushed by save, and restore state
[MeasureAs=Canvas2DLayers, RuntimeEnabled=Canvas2dLayers, CallWith=ScriptState] void beginLayer(); // push state on state stack and creates bitmap for subsequent draw ops
[MeasureAs=Canvas2DLayers, RuntimeEnabled=Canvas2dLayersWithOptions, CallWith=ScriptState, RaisesException] void beginLayer(BeginLayerOptions options); // push state on state stack and creates bitmap for subsequent draw ops
[NoAllocDirectCall, RuntimeEnabled=Canvas2dLayers, RaisesException] void endLayer(); // pop state stack if top state was pushed by beginLayer, restore state and draw the bitmap
// Clear the canvas and reset the path
void reset();
boolean isContextLost();
// transformations (default transform is the identity matrix)
[HighEntropy] void scale(unrestricted double x, unrestricted double y);
[HighEntropy, NoAllocDirectCall] void rotate(unrestricted double angle);
[HighEntropy] void translate(unrestricted double x, unrestricted double y);
[HighEntropy] void transform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
[HighEntropy] void setTransform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
[RaisesException] void setTransform(optional DOMMatrixInit transform = {});
DOMMatrix getTransform();
[NoAllocDirectCall] void resetTransform();
// compositing
attribute unrestricted double globalAlpha; // (default 1.0)
[HighEntropy] attribute DOMString globalCompositeOperation; // (default source-over)
[MeasureAs=Canvas2DFilter, SetterCallWith=ScriptState] attribute (DOMString or CanvasFilter)? filter; // (default 'none')
// image smoothing
attribute boolean imageSmoothingEnabled; // (default True)
[MeasureAs=Canvas2DImageSmoothingQuality] attribute ImageSmoothingQuality imageSmoothingQuality; // (default "low")
// colors and styles
[HighEntropy, SetterCallWith=Isolate, RaisesException=Setter, GetterCallWith=ScriptState] attribute any strokeStyle; // (default black)
[HighEntropy, SetterCallWith=Isolate, RaisesException=Setter, GetterCallWith=ScriptState] attribute any fillStyle; // (default black)
CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
[RaisesException] CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
CanvasGradient createConicGradient(double startAngle, double centerX, double centerY);
[RaisesException] CanvasPattern? createPattern(CanvasImageSource image, [LegacyNullToEmptyString] DOMString repetitionType);
// shadows
[HighEntropy] attribute unrestricted double shadowOffsetX;
[HighEntropy] attribute unrestricted double shadowOffsetY;
[HighEntropy] attribute unrestricted double shadowBlur;
[HighEntropy] attribute DOMString shadowColor;
// CanvasRect interface
[HighEntropy, NoAllocDirectCall] void clearRect(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height);
[HighEntropy, NoAllocDirectCall] void fillRect(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height);
[HighEntropy, NoAllocDirectCall] void strokeRect(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height);
// Path API (See BaseRenderingContext2D)
[HighEntropy, NoAllocDirectCall] void beginPath();
[HighEntropy] void fill(optional CanvasFillRule winding);
[HighEntropy] void fill(Path2D path, optional CanvasFillRule winding);
[HighEntropy] void stroke();
[HighEntropy] void stroke(Path2D path);
[HighEntropy] void clip(optional CanvasFillRule winding);
[HighEntropy] void clip(Path2D path, optional CanvasFillRule winding);
[HighEntropy, MeasureAs=OffscreenCanvasIsPointInPath] boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasFillRule winding);
[HighEntropy, MeasureAs=OffscreenCanvasIsPointInPath] boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional CanvasFillRule winding);
[HighEntropy, MeasureAs=OffscreenCanvasIsPointInStroke] boolean isPointInStroke(unrestricted double x, unrestricted double y);
[HighEntropy, MeasureAs=OffscreenCanvasIsPointInStroke] boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);
// text (see also the CanvasDrawingStyles interface)
[HighEntropy] void fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
[HighEntropy] void strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth);
[HighEntropy, MeasureAs=OffscreenCanvasMeasureText] TextMetrics measureText(DOMString text);
// drawing images
[RaisesException] void drawImage(CanvasImageSource image, unrestricted double x, unrestricted double y);
[RaisesException] void drawImage(CanvasImageSource image, unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height);
[RaisesException] void drawImage(CanvasImageSource image, unrestricted double sx, unrestricted double sy, unrestricted double sw, unrestricted double sh, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh);
// triangle mesh API
[MeasureAs=Canvas2DMesh, RuntimeEnabled=Canvas2dMesh, RaisesException] Mesh2DVertexBuffer createMesh2DVertexBuffer(Float32Array buffer);
[MeasureAs=Canvas2DMesh, RuntimeEnabled=Canvas2dMesh, RaisesException] Mesh2DUVBuffer createMesh2DUVBuffer(Float32Array buffer);
[MeasureAs=Canvas2DMesh, RuntimeEnabled=Canvas2dMesh, RaisesException] Mesh2DIndexBuffer createMesh2DIndexBuffer(Uint16Array buffer);
[MeasureAs=Canvas2DMesh, RuntimeEnabled=Canvas2dMesh, HighEntropy, RaisesException] void drawMesh(Mesh2DVertexBuffer vertex_buffer,
Mesh2DUVBuffer uv_buffer,
Mesh2DIndexBuffer index_buffer,
CanvasImageSource image);
// pixel manipulation
[RaisesException] ImageData createImageData(ImageData imagedata);
[RaisesException] ImageData createImageData([EnforceRange] long sw, [EnforceRange] long sh);
[RaisesException] ImageData createImageData([EnforceRange] long sw, [EnforceRange] long sh, ImageDataSettings imageDataSettings);
[HighEntropy, MeasureAs=OffscreenCanvasGetImageData, RaisesException] ImageData getImageData([EnforceRange] long sx, [EnforceRange] long sy, [EnforceRange] long sw, [EnforceRange] long sh);
[HighEntropy, MeasureAs=OffscreenCanvasGetImageData, RaisesException] ImageData getImageData([EnforceRange] long sx, [EnforceRange] long sy, [EnforceRange] long sw, [EnforceRange] long sh, ImageDataSettings imageDataSettings);
[RaisesException] void putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy);
[RaisesException] void putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy, [EnforceRange] long dirtyX, [EnforceRange] long dirtyY, [EnforceRange] long dirtyWidth, [EnforceRange] long dirtyHeight);
// Line caps/joins
attribute unrestricted double lineWidth; // (default 1)
attribute DOMString lineCap; // "butt", "round", "square" (default "butt")
attribute DOMString lineJoin; // "round", "bevel", "miter" (default "miter")
attribute unrestricted double miterLimit; // (default 10)
// dashed lines
void setLineDash(sequence<unrestricted double> dash);
sequence<unrestricted double> getLineDash();
attribute unrestricted double lineDashOffset;
// text
[HighEntropy] attribute DOMString font; // (default 10px sans-serif)
attribute DOMString textAlign; // "start", "end", "left", "right", "center" (default: "start")
attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" (default: "alphabetic")
attribute DOMString direction; // "inherit", "rtl", "ltr" (default: "inherit")
attribute DOMString fontKerning; // "auto", "normal", "none" (default: "auto")
attribute DOMString fontStretch; // "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded" (default: normal)
attribute DOMString fontVariantCaps; // "normal", "small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase", "titling-caps" (default: "normal")
attribute DOMString letterSpacing; // length in pixel (default: "0px")
attribute DOMString textRendering; // "auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision" (default: auto)
attribute DOMString wordSpacing; // length in pixel (default: "0px")
};
OffscreenCanvasRenderingContext2D includes CanvasPath;
OffscreenCanvasRenderingContext2D includes Canvas2dGPUTransfer;