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 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // FIXME: Use union types when supported: http://crbug.com/372891 | 61 // FIXME: Use union types when supported: http://crbug.com/372891 |
62 // [Custom] attribute object strokeStyle; // (default black) | 62 // [Custom] attribute object strokeStyle; // (default black) |
63 // [Custom] attribute object fillStyle; // (default black) | 63 // [Custom] attribute object fillStyle; // (default black) |
64 | 64 |
65 attribute DOMString strokeColor; // (default black) | 65 attribute DOMString strokeColor; // (default black) |
66 attribute DOMString fillColor; // (default black) | 66 attribute DOMString fillColor; // (default black) |
67 | 67 |
68 CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1); | 68 CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1); |
69 [RaisesException] CanvasGradient createRadialGradient(float x0, float y0, fl
oat r0, float x1, float y1, float r1); | 69 [RaisesException] CanvasGradient createRadialGradient(float x0, float y0, fl
oat r0, float x1, float y1, float r1); |
70 [RaisesException] CanvasPattern createPattern(HTMLCanvasElement canvas, DOMS
tring? repetitionType); | 70 [RaisesException] CanvasPattern createPattern(HTMLCanvasElement canvas, DOMS
tring? repetitionType); |
71 [RaisesException] CanvasPattern createPattern(HTMLImageElement image, DOMStr
ing? repetitionType); | 71 // Dart does not support overloads! |
| 72 // [RaisesException] CanvasPattern createPattern(HTMLImageElement image, DOM
String? repetitionType); |
72 | 73 |
73 // shadows | 74 // shadows |
74 attribute unrestricted float shadowOffsetX; | 75 attribute unrestricted float shadowOffsetX; |
75 attribute unrestricted float shadowOffsetY; | 76 attribute unrestricted float shadowOffsetY; |
76 attribute unrestricted float shadowBlur; | 77 attribute unrestricted float shadowBlur; |
77 [TreatNullAs=NullString] attribute DOMString shadowColor; | 78 [TreatNullAs=NullString] attribute DOMString shadowColor; |
78 | 79 |
79 // rects | 80 // rects |
80 void clearRect(unrestricted float x, unrestricted float y, unrestricted floa
t width, unrestricted float height); | 81 void clearRect(unrestricted float x, unrestricted float y, unrestricted floa
t width, unrestricted float height); |
81 void fillRect(unrestricted float x, unrestricted float y, unrestricted float
width, unrestricted float height); | 82 void fillRect(unrestricted float x, unrestricted float y, unrestricted float
width, unrestricted float height); |
82 void strokeRect(unrestricted float x, unrestricted float y, unrestricted flo
at width, unrestricted float height); | 83 void strokeRect(unrestricted float x, unrestricted float y, unrestricted flo
at width, unrestricted float height); |
83 | 84 |
84 // path API (see also CanvasPathMethods) | 85 // path API (see also CanvasPathMethods) |
85 void beginPath(); | 86 void beginPath(); |
86 void fill(optional CanvasFillRule winding); | 87 void fill(optional CanvasFillRule winding); |
87 void fill(Path2D path, optional CanvasFillRule winding); | 88 // void fill(Path2D path, optional CanvasFillRule winding); |
88 void stroke(); | 89 void stroke(); |
89 void stroke(Path2D path); | 90 // void stroke(Path2D path); |
90 // Focus rings | 91 // Focus rings |
91 void drawFocusIfNeeded(Element element); | 92 void drawFocusIfNeeded(Element element); |
92 void drawFocusIfNeeded(Path2D path, Element element); | 93 // void drawFocusIfNeeded(Path2D path, Element element); |
93 | 94 |
94 void clip(optional CanvasFillRule winding); | 95 void clip(optional CanvasFillRule winding); |
95 void clip(Path2D path, optional CanvasFillRule winding); | 96 // void clip(Path2D path, optional CanvasFillRule winding); |
96 boolean isPointInPath(unrestricted float x, unrestricted float y, optional C
anvasFillRule winding); | 97 boolean isPointInPath(unrestricted float x, unrestricted float y, optional C
anvasFillRule winding); |
97 boolean isPointInPath(Path2D path, unrestricted float x, unrestricted float
y, optional CanvasFillRule winding); | 98 // boolean isPointInPath(Path2D path, unrestricted float x, unrestricted flo
at y, optional CanvasFillRule winding); |
98 boolean isPointInStroke(unrestricted float x, unrestricted float y); | 99 boolean isPointInStroke(unrestricted float x, unrestricted float y); |
99 boolean isPointInStroke(Path2D path, unrestricted float x, unrestricted floa
t y); | 100 // boolean isPointInStroke(Path2D path, unrestricted float x, unrestricted f
loat y); |
100 | 101 |
101 // text (see also the CanvasDrawingStyles interface) | 102 // text (see also the CanvasDrawingStyles interface) |
102 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); |
103 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); |
104 TextMetrics measureText(DOMString text); | 105 TextMetrics measureText(DOMString text); |
105 | 106 |
106 // drawing images | 107 // drawing images |
107 [RaisesException] void drawImage(HTMLImageElement image, unrestricted float
x, unrestricted float y); | 108 [RaisesException] void drawImage(HTMLImageElement image, unrestricted float
x, unrestricted float y); |
108 [RaisesException] void drawImage(HTMLImageElement image, unrestricted float
x, unrestricted float y, unrestricted float width, unrestricted float height); | 109 //[RaisesException] void drawImage(HTMLImageElement image, unrestricted floa
t x, unrestricted float y, unrestricted float width, unrestricted float height); |
109 [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(HTMLImageElement image, 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); |
110 [RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted floa
t x, unrestricted float y); | 111 //[RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted fl
oat x, unrestricted float y); |
111 [RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted floa
t x, unrestricted float y, unrestricted float width, unrestricted float height); | 112 //[RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted fl
oat x, unrestricted float y, unrestricted float width, unrestricted float height
); |
112 [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); | 113 //[RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted fl
oat sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unr
estricted float dx, unrestricted float dy, unrestricted float dw, unrestricted f
loat dh); |
113 [RaisesException] void drawImage(ImageBitmap imageBitmap, unrestricted float
x, unrestricted float y); | 114 // [RaisesException] void drawImage(ImageBitmap imageBitmap, unrestricted fl
oat x, unrestricted float y); |
114 [RaisesException] void drawImage(ImageBitmap imageBitmap, unrestricted float
x, unrestricted float y, unrestricted float width, unrestricted float height); | 115 //[RaisesException] void drawImage(ImageBitmap imageBitmap, unrestricted flo
at x, unrestricted float y, unrestricted float width, unrestricted float height)
; |
115 [RaisesException] void drawImage(ImageBitmap imageBitmap, 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(ImageBitmap imageBitmap, unrestricted flo
at sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unre
stricted float dx, unrestricted float dy, unrestricted float dw, unrestricted fl
oat dh); |
116 | 117 |
117 // pixel manipulation | 118 // pixel manipulation |
118 ImageData createImageData(ImageData imagedata); | 119 ImageData createImageData(ImageData imagedata); |
119 [RaisesException] ImageData createImageData(float sw, float sh); | 120 //[RaisesException] ImageData createImageData(float sw, float sh); |
120 [RaisesException] ImageData getImageData(float sx, float sy, float sw, float
sh); | 121 [RaisesException] ImageData getImageData(float sx, float sy, float sw, float
sh); |
121 void putImageData(ImageData imagedata, float dx, float dy); | 122 void putImageData(ImageData imagedata, float dx, float dy); |
122 void putImageData(ImageData imagedata, float dx, float dy, float dirtyX, flo
at dirtyY, float dirtyWidth, float dirtyHeight); | 123 //void putImageData(ImageData imagedata, float dx, float dy, float dirtyX, f
loat dirtyY, float dirtyWidth, float dirtyHeight); |
123 | 124 |
124 // Context state | 125 // Context state |
125 // Should be merged with WebGL counterpart in CanvasRenderingContext, once n
o-longer experimental | 126 // Should be merged with WebGL counterpart in CanvasRenderingContext, once n
o-longer experimental |
126 boolean isContextLost(); | 127 boolean isContextLost(); |
127 | 128 |
128 Canvas2DContextAttributes getContextAttributes(); | 129 Canvas2DContextAttributes getContextAttributes(); |
129 | 130 |
130 // FIXME: factor out to CanvasDrawingStyles | 131 // FIXME: factor out to CanvasDrawingStyles |
131 // line caps/joins | 132 // line caps/joins |
132 attribute unrestricted float lineWidth; // (default 1) | 133 attribute unrestricted float lineWidth; // (default 1) |
133 [TreatNullAs=NullString] attribute DOMString lineCap; // "butt", "round", "s
quare" (default "butt") | 134 [TreatNullAs=NullString] attribute DOMString lineCap; // "butt", "round", "s
quare" (default "butt") |
134 [TreatNullAs=NullString] attribute DOMString lineJoin; // "round", "bevel",
"miter" (default "miter") | 135 [TreatNullAs=NullString] attribute DOMString lineJoin; // "round", "bevel",
"miter" (default "miter") |
135 attribute unrestricted float miterLimit; // (default 10) | 136 attribute unrestricted float miterLimit; // (default 10) |
136 | 137 |
137 // dashed lines | 138 // dashed lines |
138 void setLineDash(sequence<unrestricted float> dash); | 139 // TODO(eseidel): Generator doesn't handle List<unrestricted float> yet. |
139 sequence<unrestricted float> getLineDash(); | 140 // void setLineDash(sequence<unrestricted float> dash); |
| 141 // sequence<unrestricted float> getLineDash(); |
140 attribute unrestricted float lineDashOffset; | 142 attribute unrestricted float lineDashOffset; |
141 | 143 |
142 // text | 144 // text |
143 attribute DOMString font; // (default 10px sans-serif) | 145 attribute DOMString font; // (default 10px sans-serif) |
144 attribute DOMString textAlign; // "start", "end", "left", "right", "center"
(default: "start") | 146 attribute DOMString textAlign; // "start", "end", "left", "right", "center"
(default: "start") |
145 attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic
", "ideographic", "bottom" (default: "alphabetic") | 147 attribute DOMString textBaseline; // "top", "hanging", "middle", "alphabetic
", "ideographic", "bottom" (default: "alphabetic") |
146 attribute DOMString direction; // "inherit", "rtl", "ltr" (default: "inherit
") | 148 attribute DOMString direction; // "inherit", "rtl", "ltr" (default: "inherit
") |
147 | 149 |
148 // Non-standard APIs. Candidates for deprecation | 150 // Non-standard APIs. Candidates for deprecation |
149 // https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D | 151 // https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D |
150 void setLineWidth(unrestricted float width); | 152 void setLineWidth(unrestricted float width); |
151 void setLineCap(DOMString cap); | 153 void setLineCap(DOMString cap); |
152 void setLineJoin(DOMString join); | 154 void setLineJoin(DOMString join); |
153 void setMiterLimit(unrestricted float limit); | 155 void setMiterLimit(unrestricted float limit); |
154 void clearShadow(); | 156 void clearShadow(); |
155 void setStrokeColor(DOMString color, optional unrestricted float alpha); | 157 void setStrokeColor(DOMString color, optional unrestricted float alpha); |
156 void setStrokeColor(unrestricted float grayLevel, optional unrestricted floa
t alpha); | 158 //void setStrokeColor(unrestricted float grayLevel, optional unrestricted fl
oat alpha); |
157 void setStrokeColor(unrestricted float r, unrestricted float g, unrestricted
float b, unrestricted float a); | 159 //void setStrokeColor(unrestricted float r, unrestricted float g, unrestrict
ed float b, unrestricted float a); |
158 void setStrokeColor(unrestricted float c, unrestricted float m, unrestricted
float y, unrestricted float k, unrestricted float a); | 160 //void setStrokeColor(unrestricted float c, unrestricted float m, unrestrict
ed float y, unrestricted float k, unrestricted float a); |
159 void setFillColor(DOMString color, optional unrestricted float alpha); | 161 void setFillColor(DOMString color, optional unrestricted float alpha); |
160 void setFillColor(unrestricted float grayLevel, optional unrestricted float
alpha); | 162 //void setFillColor(unrestricted float grayLevel, optional unrestricted floa
t alpha); |
161 void setFillColor(unrestricted float r, unrestricted float g, unrestricted f
loat b, unrestricted float a); | 163 //void setFillColor(unrestricted float r, unrestricted float g, unrestricted
float b, unrestricted float a); |
162 void setFillColor(unrestricted float c, unrestricted float m, unrestricted f
loat y, unrestricted float k, unrestricted float a); | 164 //void setFillColor(unrestricted float c, unrestricted float m, unrestricted
float y, unrestricted float k, unrestricted float a); |
163 void drawImageFromRect( | 165 void drawImageFromRect( |
164 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, |
165 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); |
166 void setShadow(unrestricted float width, unrestricted float height, unrestri
cted float blur, optional DOMString color, optional unrestricted float alpha); | 168 void setShadow(unrestricted float width, unrestricted float height, unrestri
cted float blur, optional DOMString color, optional unrestricted float alpha); |
167 void setShadow(unrestricted float width, unrestricted float height, unrestri
cted float blur, unrestricted float grayLevel, optional unrestricted float alpha
); | 169 //void setShadow(unrestricted float width, unrestricted float height, unrest
ricted float blur, unrestricted float grayLevel, optional unrestricted float alp
ha); |
168 void setShadow(unrestricted float width, unrestricted float height, unrestri
cted float blur, unrestricted float r, unrestricted float g, unrestricted float
b, unrestricted float a); | 170 //void setShadow(unrestricted float width, unrestricted float height, unrest
ricted float blur, unrestricted float r, unrestricted float g, unrestricted floa
t b, unrestricted float a); |
169 void setShadow(unrestricted float width, unrestricted float height, unrestri
cted float blur, unrestricted float c, unrestricted float m, unrestricted float
y, unrestricted float k, unrestricted float a); | 171 //void setShadow(unrestricted float width, unrestricted float height, unrest
ricted float blur, unrestricted float c, unrestricted float m, unrestricted floa
t y, unrestricted float k, unrestricted float a); |
170 }; | 172 }; |
171 | 173 |
172 CanvasRenderingContext2D implements CanvasPathMethods; | 174 CanvasRenderingContext2D implements CanvasPathMethods; |
OLD | NEW |