blob: 742d2fc83e8c4363affa32dde9edf64e1810cf71 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Note: The official spec is WIP at wiki.whatwg.org/wiki/OffscreenCanvas.
[
Exposed=(Window,Worker),
RuntimeEnabled=ExperimentalCanvasFeatures,
] interface OffscreenCanvasRenderingContext2D {
// back-reference to the canvas
[ImplementedAs=getOffscreenCanvas] readonly attribute OffscreenCanvas offscreenCanvas;
// colors and styles
attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black)
attribute (DOMString or CanvasGradient or CanvasPattern) 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);
[CallWith=ExecutionContext, RaisesException] CanvasPattern? createPattern(CanvasImageSource image, [TreatNullAs=NullString] DOMString repetitionType);
// CanvasRect interface
void clearRect(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height);
void fillRect(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height);
void strokeRect(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height);
// Path API (See BaseRenderingContext2D)
void beginPath();
void fill(optional CanvasFillRule winding);
void fill(Path2D path, optional CanvasFillRule winding);
void stroke();
void stroke(Path2D path);
void clip();
void clip(Path2D path);
// drawing images
[CallWith=ExecutionContext, RaisesException] void drawImage(CanvasImageSource image, unrestricted double x, unrestricted double y);
[CallWith=ExecutionContext, RaisesException] void drawImage(CanvasImageSource image, unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height);
[CallWith=ExecutionContext, 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);
// 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;
// state
void save(); // push state on state stack
void restore(); // pop state stack and restore state
// transformations (default transform is the identity matrix)
void scale(unrestricted double x, unrestricted double y);
void rotate(unrestricted double angle);
void translate(unrestricted double x, unrestricted double y);
void transform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
void setTransform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f);
void resetTransform();
// shadows
attribute unrestricted double shadowOffsetX;
attribute unrestricted double shadowOffsetY;
attribute unrestricted double shadowBlur;
attribute DOMString shadowColor;
// pixel manipulation
[RaisesException] ImageData createImageData(ImageData imagedata);
[RaisesException] ImageData createImageData(double sw, double sh);
[RaisesException] ImageData getImageData(double sx, double sy, double sw, double sh);
[RaisesException] void putImageData(ImageData imagedata, double dx, double dy);
[RaisesException] void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
};
OffscreenCanvasRenderingContext2D implements CanvasPathMethods;