OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-elemen
t.html#canvasrenderingcontext2d | 26 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-elemen
t.html#canvasrenderingcontext2d |
27 | 27 |
28 // FIXME: float => double throughout | 28 // FIXME: float => double throughout |
29 // FIXME: Use union type in drawImage and createPattern once supported: | |
30 // http://crbug.com/372891 | |
31 typedef (HTMLImageElement or | 29 typedef (HTMLImageElement or |
32 HTMLVideoElement or | 30 HTMLVideoElement or |
33 HTMLCanvasElement // or | 31 HTMLCanvasElement or |
34 // CanvasRenderingContext2D or | 32 // CanvasRenderingContext2D or |
35 // ImageBitmap | 33 ImageBitmap) CanvasImageSource; |
36 ) CanvasImageSource; | |
37 | 34 |
38 enum CanvasFillRule { "nonzero", "evenodd" }; | 35 enum CanvasFillRule { "nonzero", "evenodd" }; |
39 | 36 |
40 [ | 37 [ |
41 TypeChecking=(Interface,Unrestricted), | 38 TypeChecking=(Interface,Unrestricted), |
42 WillBeGarbageCollected, | 39 WillBeGarbageCollected, |
43 ] interface CanvasRenderingContext2D { | 40 ] interface CanvasRenderingContext2D { |
44 // back-reference to the canvas | 41 // back-reference to the canvas |
45 readonly attribute HTMLCanvasElement canvas; | 42 readonly attribute HTMLCanvasElement canvas; |
46 | 43 |
(...skipping 17 matching lines...) Expand all Loading... |
64 // image smoothing | 61 // image smoothing |
65 [ImplementedAs=imageSmoothingEnabled, MeasureAs=PrefixedImageSmoothingEnable
d] attribute boolean webkitImageSmoothingEnabled; | 62 [ImplementedAs=imageSmoothingEnabled, MeasureAs=PrefixedImageSmoothingEnable
d] attribute boolean webkitImageSmoothingEnabled; |
66 [MeasureAs=UnprefixedImageSmoothingEnabled] attribute boolean imageSmoothing
Enabled; | 63 [MeasureAs=UnprefixedImageSmoothingEnabled] attribute boolean imageSmoothing
Enabled; |
67 | 64 |
68 // colors and styles (see also the CanvasDrawingStyles interface) | 65 // colors and styles (see also the CanvasDrawingStyles interface) |
69 // FIXME: Use union types when supported: http://crbug.com/372891 | 66 // FIXME: Use union types when supported: http://crbug.com/372891 |
70 [Custom] attribute object strokeStyle; // (default black) | 67 [Custom] attribute object strokeStyle; // (default black) |
71 [Custom] attribute object fillStyle; // (default black) | 68 [Custom] attribute object fillStyle; // (default black) |
72 CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1); | 69 CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1); |
73 [RaisesException] CanvasGradient createRadialGradient(float x0, float y0, fl
oat r0, float x1, float y1, float r1); | 70 [RaisesException] CanvasGradient createRadialGradient(float x0, float y0, fl
oat r0, float x1, float y1, float r1); |
74 [RaisesException] CanvasPattern createPattern(HTMLCanvasElement canvas, DOMS
tring? repetitionType); | 71 [RaisesException] CanvasPattern createPattern(CanvasImageSource image, DOMSt
ring? repetitionType); |
75 [RaisesException] CanvasPattern createPattern(HTMLImageElement image, DOMStr
ing? repetitionType); | |
76 [RaisesException] CanvasPattern createPattern(HTMLVideoElement image, DOMStr
ing? repetitionType); | |
77 | 72 |
78 // shadows | 73 // shadows |
79 attribute unrestricted float shadowOffsetX; | 74 attribute unrestricted float shadowOffsetX; |
80 attribute unrestricted float shadowOffsetY; | 75 attribute unrestricted float shadowOffsetY; |
81 attribute unrestricted float shadowBlur; | 76 attribute unrestricted float shadowBlur; |
82 [TreatNullAs=NullString] attribute DOMString shadowColor; | 77 [TreatNullAs=NullString] attribute DOMString shadowColor; |
83 | 78 |
84 // rects | 79 // rects |
85 void clearRect(unrestricted float x, unrestricted float y, unrestricted floa
t width, unrestricted float height); | 80 void clearRect(unrestricted float x, unrestricted float y, unrestricted floa
t width, unrestricted float height); |
86 void fillRect(unrestricted float x, unrestricted float y, unrestricted float
width, unrestricted float height); | 81 void fillRect(unrestricted float x, unrestricted float y, unrestricted float
width, unrestricted float height); |
(...skipping 16 matching lines...) Expand all Loading... |
103 boolean isPointInPath(Path2D path, unrestricted float x, unrestricted float
y, optional CanvasFillRule winding); | 98 boolean isPointInPath(Path2D path, unrestricted float x, unrestricted float
y, optional CanvasFillRule winding); |
104 boolean isPointInStroke(unrestricted float x, unrestricted float y); | 99 boolean isPointInStroke(unrestricted float x, unrestricted float y); |
105 boolean isPointInStroke(Path2D path, unrestricted float x, unrestricted floa
t y); | 100 boolean isPointInStroke(Path2D path, unrestricted float x, unrestricted floa
t y); |
106 | 101 |
107 // text (see also the CanvasDrawingStyles interface) | 102 // text (see also the CanvasDrawingStyles interface) |
108 void fillText(DOMString text, unrestricted float x, unrestricted float y, op
tional unrestricted float maxWidth); | 103 void fillText(DOMString text, unrestricted float x, unrestricted float y, op
tional unrestricted float maxWidth); |
109 void strokeText(DOMString text, unrestricted float x, unrestricted float y,
optional unrestricted float maxWidth); | 104 void strokeText(DOMString text, unrestricted float x, unrestricted float y,
optional unrestricted float maxWidth); |
110 TextMetrics measureText(DOMString text); | 105 TextMetrics measureText(DOMString text); |
111 | 106 |
112 // drawing images | 107 // drawing images |
113 [RaisesException] void drawImage(HTMLImageElement image, unrestricted float
x, unrestricted float y); | 108 [RaisesException] void drawImage(CanvasImageSource image, unrestricted float
x, unrestricted float y); |
114 [RaisesException] void drawImage(HTMLImageElement image, unrestricted float
x, unrestricted float y, unrestricted float width, unrestricted float height); | 109 [RaisesException] void drawImage(CanvasImageSource image, unrestricted float
x, unrestricted float y, unrestricted float width, unrestricted float height); |
115 [RaisesException] void drawImage(HTMLImageElement image, unrestricted float
sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestr
icted float dx, unrestricted float dy, unrestricted float dw, unrestricted float
dh); | 110 [RaisesException] void drawImage(CanvasImageSource image, unrestricted float
sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrest
ricted float dx, unrestricted float dy, unrestricted float dw, unrestricted floa
t dh); |
116 [RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted floa
t x, unrestricted float y); | |
117 [RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted floa
t x, unrestricted float y, unrestricted float width, unrestricted float height); | |
118 [RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted floa
t sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unres
tricted float dx, unrestricted float dy, unrestricted float dw, unrestricted flo
at dh); | |
119 [RaisesException] void drawImage(HTMLVideoElement video, unrestricted float
x, unrestricted float y); | |
120 [RaisesException] void drawImage(HTMLVideoElement video, unrestricted float
x, unrestricted float y, unrestricted float width, unrestricted float height); | |
121 [RaisesException] void drawImage(HTMLVideoElement video, unrestricted float
sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestr
icted float dx, unrestricted float dy, unrestricted float dw, unrestricted float
dh); | |
122 [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void drawImage(
ImageBitmap imageBitmap, unrestricted float x, unrestricted float y); | |
123 [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void drawImage(
ImageBitmap imageBitmap, unrestricted float x, unrestricted float y, unrestricte
d float width, unrestricted float height); | |
124 [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void drawImage(
ImageBitmap imageBitmap, unrestricted float sx, unrestricted float sy, unrestric
ted float sw, unrestricted float sh, unrestricted float dx, unrestricted float d
y, unrestricted float dw, unrestricted float dh); | |
125 | 111 |
126 // hit regions | 112 // hit regions |
127 [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void addHitRegi
on(optional HitRegionOptions options); | 113 [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void addHitRegi
on(optional HitRegionOptions options); |
128 [RuntimeEnabled=ExperimentalCanvasFeatures] void removeHitRegion(DOMString i
d); | 114 [RuntimeEnabled=ExperimentalCanvasFeatures] void removeHitRegion(DOMString i
d); |
129 [RuntimeEnabled=ExperimentalCanvasFeatures] void clearHitRegions(); | 115 [RuntimeEnabled=ExperimentalCanvasFeatures] void clearHitRegions(); |
130 | 116 |
131 // pixel manipulation | 117 // pixel manipulation |
132 ImageData createImageData(ImageData imagedata); | 118 ImageData createImageData(ImageData imagedata); |
133 [RaisesException] ImageData createImageData(float sw, float sh); | 119 [RaisesException] ImageData createImageData(float sw, float sh); |
134 [RaisesException] ImageData getImageData(float sx, float sy, float sw, float
sh); | 120 [RaisesException] ImageData getImageData(float sx, float sy, float sw, float
sh); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 [MeasureAs=CanvasRenderingContext2DDrawImageFromRect] void drawImageFromRect
( | 165 [MeasureAs=CanvasRenderingContext2DDrawImageFromRect] void drawImageFromRect
( |
180 HTMLImageElement? image, optional unrestricted float sx, optional unrest
ricted float sy, optional unrestricted float sw, optional unrestricted float sh, | 166 HTMLImageElement? image, optional unrestricted float sx, optional unrest
ricted float sy, optional unrestricted float sw, optional unrestricted float sh, |
181 optional unrestricted float dx, optional unrestricted float dy, optional
unrestricted float dw, optional unrestricted float dh, optional DOMString compo
siteOperation); | 167 optional unrestricted float dx, optional unrestricted float dy, optional
unrestricted float dw, optional unrestricted float dh, optional DOMString compo
siteOperation); |
182 [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted fl
oat width, unrestricted float height, unrestricted float blur, optional DOMStrin
g color, optional unrestricted float alpha); | 168 [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted fl
oat width, unrestricted float height, unrestricted float blur, optional DOMStrin
g color, optional unrestricted float alpha); |
183 [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted fl
oat width, unrestricted float height, unrestricted float blur, unrestricted floa
t grayLevel, optional unrestricted float alpha); | 169 [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted fl
oat width, unrestricted float height, unrestricted float blur, unrestricted floa
t grayLevel, optional unrestricted float alpha); |
184 [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted fl
oat width, unrestricted float height, unrestricted float blur, unrestricted floa
t r, unrestricted float g, unrestricted float b, unrestricted float a); | 170 [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted fl
oat width, unrestricted float height, unrestricted float blur, unrestricted floa
t r, unrestricted float g, unrestricted float b, unrestricted float a); |
185 [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted fl
oat width, unrestricted float height, unrestricted float blur, unrestricted floa
t c, unrestricted float m, unrestricted float y, unrestricted float k, unrestric
ted float a); | 171 [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted fl
oat width, unrestricted float height, unrestricted float blur, unrestricted floa
t c, unrestricted float m, unrestricted float y, unrestricted float k, unrestric
ted float a); |
186 }; | 172 }; |
187 | 173 |
188 CanvasRenderingContext2D implements CanvasPathMethods; | 174 CanvasRenderingContext2D implements CanvasPathMethods; |
OLD | NEW |