1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
enum CanvasFillRule { "nonzero", "evenodd" };
// https://html.spec.whatwg.org/multipage/#2dcontext
typedef (HTMLImageElement or
/* HTMLVideoElement or */
HTMLCanvasElement or
CanvasRenderingContext2D or
/* ImageBitmap or */
// This should probably be a CSSImageValue
// https://github.com/w3c/css-houdini-drafts/issues/416
CSSStyleValue) CanvasImageSource;
//[Constructor(optional unsigned long width, unsigned long height)]
interface CanvasRenderingContext2D {
// back-reference to the canvas
readonly attribute HTMLCanvasElement canvas;
// canvas dimensions
// attribute unsigned long width;
// attribute unsigned long height;
// for contexts that aren't directly fixed to a specific canvas
//void commit(); // push the image to the output bitmap
};
CanvasRenderingContext2D implements CanvasState;
CanvasRenderingContext2D implements CanvasTransform;
CanvasRenderingContext2D implements CanvasCompositing;
CanvasRenderingContext2D implements CanvasImageSmoothing;
CanvasRenderingContext2D implements CanvasFillStrokeStyles;
CanvasRenderingContext2D implements CanvasShadowStyles;
CanvasRenderingContext2D implements CanvasRect;
CanvasRenderingContext2D implements CanvasDrawPath;
CanvasRenderingContext2D implements CanvasUserInterface;
CanvasRenderingContext2D implements CanvasText;
CanvasRenderingContext2D implements CanvasDrawImage;
CanvasRenderingContext2D implements CanvasHitRegion;
CanvasRenderingContext2D implements CanvasImageData;
CanvasRenderingContext2D implements CanvasPathDrawingStyles;
CanvasRenderingContext2D implements CanvasTextDrawingStyles;
CanvasRenderingContext2D implements CanvasPath;
[NoInterfaceObject, Exposed=(Window, PaintWorklet)]
interface CanvasState {
// state
void save(); // push state on state stack
void restore(); // pop state stack and restore state
};
[NoInterfaceObject, Exposed=(Window, PaintWorklet)]
interface CanvasTransform {
// 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);
// [NewObject] DOMMatrix getTransform();
void setTransform(unrestricted double a,
unrestricted double b,
unrestricted double c,
unrestricted double d,
unrestricted double e,
unrestricted double f);
// void setTransform(optional DOMMatrixInit matrix);
void resetTransform();
};
[NoInterfaceObject, Exposed=(Window, PaintWorklet)]
interface CanvasCompositing {
// compositing
attribute unrestricted double globalAlpha; // (default 1.0)
attribute DOMString globalCompositeOperation; // (default source-over)
};
[NoInterfaceObject, Exposed=(Window, PaintWorklet)]
interface CanvasImageSmoothing {
// image smoothing
attribute boolean imageSmoothingEnabled; // (default true)
// attribute ImageSmoothingQuality imageSmoothingQuality; // (default low)
};
[NoInterfaceObject, Exposed=(Window, PaintWorklet)]
interface CanvasFillStrokeStyles {
// colours and styles (see also the CanvasDrawingStyles interface)
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);
[Throws]
CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
[Throws]
CanvasPattern createPattern(CanvasImageSource image, [TreatNullAs=EmptyString] DOMString repetition);
};
[NoInterfaceObject, Exposed=(Window, PaintWorklet)]
interface CanvasShadowStyles {
// shadows
attribute unrestricted double shadowOffsetX; // (default 0)
attribute unrestricted double shadowOffsetY; // (default 0)
attribute unrestricted double shadowBlur; // (default 0)
attribute DOMString shadowColor; // (default transparent black)
};
[NoInterfaceObject, Exposed=(Window, PaintWorklet)]
interface CanvasRect {
// rects
//[LenientFloat]
void clearRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
//[LenientFloat]
void fillRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
//[LenientFloat]
void strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
};
[NoInterfaceObject, Exposed=(Window, PaintWorklet)]
interface CanvasDrawPath {
// path API (see also CanvasPathMethods)
void beginPath();
void fill(optional CanvasFillRule fillRule = "nonzero");
//void fill(Path2D path, optional CanvasFillRule fillRule = "nonzero");
void stroke();
//void stroke(Path2D path);
//void drawFocusIfNeeded(Element element);
//void drawFocusIfNeeded(Path2D path, Element element);
//void scrollPathIntoView();
//void scrollPathIntoView(Path2D path);
void clip(optional CanvasFillRule fillRule = "nonzero");
//void clip(Path2D path, optional CanvasFillRule fillRule = "nonzero");
//void resetClip();
boolean isPointInPath(unrestricted double x, unrestricted double y,
optional CanvasFillRule fillRule = "nonzero");
//boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y,
// optional CanvasFillRule fillRule = "nonzero");
//boolean isPointInStroke(unrestricted double x, unrestricted double y);
//boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y);
};
[NoInterfaceObject]
interface CanvasUserInterface {
// TODO?
};
[NoInterfaceObject]
interface CanvasText {
// text (see also the CanvasDrawingStyles interface)
[Pref="dom.canvas-text.enabled"]
void fillText(DOMString text, unrestricted double x, unrestricted double y,
optional unrestricted double maxWidth);
//void strokeText(DOMString text, unrestricted double x, unrestricted double y,
// optional unrestricted double maxWidth);
//TextMetrics measureText(DOMString text);
};
[NoInterfaceObject, Exposed=(Window, PaintWorklet)]
interface CanvasDrawImage {
// drawing images
[Throws]
void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy);
[Throws]
void drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy,
unrestricted double dw, unrestricted double dh);
[Throws]
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);
};
[NoInterfaceObject]
interface CanvasHitRegion {
// hit regions
//void addHitRegion(optional HitRegionOptions options);
//void removeHitRegion(DOMString id);
//void clearHitRegions();
};
[NoInterfaceObject]
interface CanvasImageData {
// pixel manipulation
[Throws]
ImageData createImageData(double sw, double sh);
[Throws]
ImageData createImageData(ImageData imagedata);
[Throws]
ImageData getImageData(double sx, double sy, double sw, double sh);
void putImageData(ImageData imagedata, double dx, double dy);
void putImageData(ImageData imagedata,
double dx, double dy,
double dirtyX, double dirtyY,
double dirtyWidth, double dirtyHeight);
};
CanvasRenderingContext2D implements CanvasPathDrawingStyles;
CanvasRenderingContext2D implements CanvasTextDrawingStyles;
CanvasRenderingContext2D implements CanvasPath;
enum CanvasLineCap { "butt", "round", "square" };
enum CanvasLineJoin { "round", "bevel", "miter"};
enum CanvasTextAlign { "start", "end", "left", "right", "center" };
enum CanvasTextBaseline { "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" };
enum CanvasDirection { "ltr", "rtl", "inherit" };
[NoInterfaceObject, Exposed=(Window, PaintWorklet)]
interface CanvasPathDrawingStyles {
// line caps/joins
attribute unrestricted double lineWidth; // (default 1)
attribute CanvasLineCap lineCap; // "butt", "round", "square" (default "butt")
attribute CanvasLineJoin lineJoin; // "round", "bevel", "miter" (default "miter")
attribute unrestricted double miterLimit; // (default 10)
// dashed lines
//void setLineDash(sequence<unrestricted double> segments); // default empty
//sequence<unrestricted double> getLineDash();
//attribute unrestricted double lineDashOffset;
};
[NoInterfaceObject]
interface CanvasTextDrawingStyles {
// text
//attribute DOMString font; // (default 10px sans-serif)
//attribute CanvasTextAlign textAlign; // "start", "end", "left", "right", "center" (default: "start")
//attribute CanvasTextBaseline textBaseline; // "top", "hanging", "middle", "alphabetic",
// "ideographic", "bottom" (default: "alphabetic")
//attribute CanvasDirection direction; // "ltr", "rtl", "inherit" (default: "inherit")
};
[NoInterfaceObject, Exposed=(Window, Worker, PaintWorklet)]
interface CanvasPath {
// shared path API methods
void closePath();
void moveTo(unrestricted double x, unrestricted double y);
void lineTo(unrestricted double x, unrestricted double y);
void quadraticCurveTo(unrestricted double cpx, unrestricted double cpy,
unrestricted double x, unrestricted double y);
void bezierCurveTo(unrestricted double cp1x,
unrestricted double cp1y,
unrestricted double cp2x,
unrestricted double cp2y,
unrestricted double x,
unrestricted double y);
[Throws]
void arcTo(unrestricted double x1, unrestricted double y1,
unrestricted double x2, unrestricted double y2,
unrestricted double radius);
// [LenientFloat] void arcTo(double x1, double y1, double x2, double y2,
// double radiusX, double radiusY, double rotation);
void rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h);
[Throws]
void arc(unrestricted double x, unrestricted double y, unrestricted double radius,
unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false);
// [LenientFloat] void ellipse(double x, double y, double radiusX, double radiusY,
// double rotation, double startAngle, double endAngle,
// boolean anticlockwise);
[Throws]
void ellipse(unrestricted double x, unrestricted double y, unrestricted double radius_x,
unrestricted double radius_y, unrestricted double rotation, unrestricted double startAngle,
unrestricted double endAngle, optional boolean anticlockwise = false);
};
|