2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 enum CanvasWindingRule { "nonzero", "evenodd" };
28 interface CanvasRenderingContext2D : CanvasRenderingContext {
33 [RuntimeEnabled=ExperimentalCanvasFeatures, Immutable] attribute SVGMatrix currentTransform;
34 void scale(float sx, float sy);
35 void rotate(float angle);
36 void translate(float tx, float ty);
37 void transform(float m11, float m12, float m21, float m22, float dx, float dy);
38 void setTransform(float m11, float m12, float m21, float m22, float dx, float dy);
39 void resetTransform();
41 attribute float globalAlpha;
42 [TreatNullAs=NullString] attribute DOMString globalCompositeOperation;
44 [RaisesException] CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1);
45 [RaisesException] CanvasGradient createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1);
47 attribute float lineWidth;
48 [TreatNullAs=NullString] attribute DOMString lineCap;
49 [TreatNullAs=NullString] attribute DOMString lineJoin;
50 attribute float miterLimit;
52 attribute float shadowOffsetX;
53 attribute float shadowOffsetY;
54 attribute float shadowBlur;
55 [TreatNullAs=NullString] attribute DOMString shadowColor;
57 void setLineDash(sequence<float> dash);
58 sequence<float> getLineDash();
59 attribute float lineDashOffset;
61 // FIXME: These attributes should be implemented.
62 // [Custom] attribute Array webkitLineDash;
63 // attribute float webkitLineDashOffset;
65 void clearRect(float x, float y, float width, float height);
66 void fillRect(float x, float y, float width, float height);
70 attribute Path currentPath;
72 // FIXME: These methods should be shared with CanvasRenderingContext2D in the CanvasPathMethods interface.
74 void moveTo(float x, float y);
75 void lineTo(float x, float y);
76 void quadraticCurveTo(float cpx, float cpy, float x, float y);
77 void bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y);
78 [RaisesException] void arcTo(float x1, float y1, float x2, float y2, float radius);
79 void rect(float x, float y, float width, float height);
80 [RaisesException] void arc(float x, float y, float radius, float startAngle, float endAngle, [Default=Undefined] optional boolean anticlockwise);
81 [RaisesException] void ellipse(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float endAngle, boolean anticlockwise);
83 void fill(optional CanvasWindingRule winding);
85 void clip(optional CanvasWindingRule winding);
86 boolean isPointInPath(float x, float y, optional CanvasWindingRule winding);
87 boolean isPointInStroke(float x, float y);
90 attribute DOMString font;
91 attribute DOMString textAlign;
92 attribute DOMString textBaseline;
94 TextMetrics measureText(DOMString text);
98 void setAlpha(float alpha);
99 void setCompositeOperation(DOMString compositeOperation);
101 void setLineWidth(float width);
102 void setLineCap(DOMString cap);
103 void setLineJoin(DOMString join);
104 void setMiterLimit(float limit);
108 void fillText(DOMString text, float x, float y, optional float maxWidth);
109 void strokeText(DOMString text, float x, float y, optional float maxWidth);
111 void setStrokeColor([StrictTypeChecking] DOMString color, optional float alpha);
112 void setStrokeColor(float grayLevel, optional float alpha);
113 void setStrokeColor(float r, float g, float b, float a);
114 void setStrokeColor(float c, float m, float y, float k, float a);
116 void setFillColor([StrictTypeChecking] DOMString color, optional float alpha);
117 void setFillColor(float grayLevel, optional float alpha);
118 void setFillColor(float r, float g, float b, float a);
119 void setFillColor(float c, float m, float y, float k, float a);
121 void strokeRect(float x, float y, float width, float height);
123 [RaisesException] void drawImage(HTMLImageElement? image, float x, float y);
124 [RaisesException] void drawImage(HTMLImageElement? image, float x, float y, float width, float height);
125 [RaisesException] void drawImage(HTMLImageElement? image, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh);
126 [RaisesException] void drawImage(HTMLCanvasElement? canvas, float x, float y);
127 [RaisesException] void drawImage(HTMLCanvasElement? canvas, float x, float y, float width, float height);
128 [RaisesException] void drawImage(HTMLCanvasElement? canvas, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh);
129 [RaisesException] void drawImage(HTMLVideoElement? video, float x, float y);
130 [RaisesException] void drawImage(HTMLVideoElement? video, float x, float y, float width, float height);
131 [RaisesException] void drawImage(HTMLVideoElement? video, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh);
132 [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void drawImage(ImageBitmap? imageBitmap, float x, float y);
133 [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void drawImage(ImageBitmap? imageBitmap, float x, float y, float width, float height);
134 [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void drawImage(ImageBitmap? imageBitmap, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh);
136 void drawImageFromRect(HTMLImageElement image,
137 optional float sx, optional float sy, optional float sw, optional float sh,
138 optional float dx, optional float dy, optional float dw, optional float dh,
139 optional DOMString compositeOperation);
141 void setShadow(float width, float height, float blur, [StrictTypeChecking] optional DOMString color, optional float alpha);
142 void setShadow(float width, float height, float blur, float grayLevel, optional float alpha);
143 void setShadow(float width, float height, float blur, float r, float g, float b, float a);
144 void setShadow(float width, float height, float blur, float c, float m, float y, float k, float a);
146 [RaisesException] void putImageData(ImageData? imagedata, float dx, float dy);
147 [RaisesException] void putImageData(ImageData? imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
149 [RaisesException] void webkitPutImageDataHD(ImageData? imagedata, float dx, float dy);
150 [RaisesException] void webkitPutImageDataHD(ImageData? imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight);
152 [RaisesException] CanvasPattern createPattern(HTMLCanvasElement? canvas, [TreatNullAs=NullString] DOMString repetitionType);
153 [RaisesException] CanvasPattern createPattern(HTMLImageElement? image, [TreatNullAs=NullString] DOMString repetitionType);
154 [RaisesException] ImageData createImageData(ImageData? imagedata);
155 [RaisesException] ImageData createImageData(float sw, float sh);
157 [Custom] attribute custom strokeStyle;
158 [Custom] attribute custom fillStyle;
160 // pixel manipulation
161 [RaisesException] ImageData getImageData(float sx, float sy, float sw, float sh);
163 [RaisesException] ImageData webkitGetImageDataHD(float sx, float sy, float sw, float sh);
166 [RuntimeEnabled=ExperimentalCanvasFeatures] void drawSystemFocusRing(Element element);
167 [RuntimeEnabled=ExperimentalCanvasFeatures] boolean drawCustomFocusRing(Element element);
169 readonly attribute float webkitBackingStorePixelRatio;
171 [ImplementedAs=imageSmoothingEnabled] attribute boolean webkitImageSmoothingEnabled;
172 attribute boolean imageSmoothingEnabled;
174 Canvas2DContextAttributes getContextAttributes();