| /* |
| * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions |
| * are met: |
| * 1. Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * 2. Redistributions in binary form must reproduce the above copyright |
| * notice, this list of conditions and the following disclaimer in the |
| * documentation and/or other materials provided with the distribution. |
| * |
| * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| |
| enum CanvasWindingRule { "nonzero", "evenodd" }; |
| |
| [ |
| TypeChecking=Interface|Nullable|Unrestricted, |
| WillBeGarbageCollected, |
| ] interface CanvasRenderingContext2D { |
| |
| readonly attribute HTMLCanvasElement canvas; |
| |
| void save(); |
| void restore(); |
| |
| [RuntimeEnabled=ExperimentalCanvasFeatures] attribute SVGMatrix currentTransform; |
| void scale(unrestricted float sx, unrestricted float sy); |
| void rotate(unrestricted float angle); |
| void translate(unrestricted float tx, unrestricted float ty); |
| void transform(unrestricted float m11, unrestricted float m12, unrestricted float m21, unrestricted float m22, unrestricted float dx, unrestricted float dy); |
| void setTransform(unrestricted float m11, unrestricted float m12, unrestricted float m21, unrestricted float m22, unrestricted float dx, unrestricted float dy); |
| void resetTransform(); |
| |
| attribute unrestricted float globalAlpha; |
| [TreatNullAs=NullString] attribute DOMString globalCompositeOperation; |
| |
| CanvasGradient createLinearGradient(float x0, float y0, float x1, float y1); |
| [RaisesException] CanvasGradient createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1); |
| |
| attribute unrestricted float lineWidth; |
| [TreatNullAs=NullString] attribute DOMString lineCap; |
| [TreatNullAs=NullString] attribute DOMString lineJoin; |
| attribute unrestricted float miterLimit; |
| |
| attribute unrestricted float shadowOffsetX; |
| attribute unrestricted float shadowOffsetY; |
| attribute unrestricted float shadowBlur; |
| [TreatNullAs=NullString] attribute DOMString shadowColor; |
| |
| void setLineDash(sequence<unrestricted float> dash); |
| sequence<unrestricted float> getLineDash(); |
| attribute unrestricted float lineDashOffset; |
| |
| void clearRect(unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height); |
| void fillRect(unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height); |
| |
| void beginPath(); |
| |
| // FIXME: Simplify these using optional CanvasWindingRule once crbug.com/339000 gets fixed. |
| void fill(); |
| [RuntimeEnabled=Path2D] void fill(Path2D path); |
| void fill(CanvasWindingRule winding); |
| [RuntimeEnabled=Path2D] void fill(Path2D path, CanvasWindingRule winding); |
| void stroke(); |
| [RuntimeEnabled=Path2D] void stroke(Path2D path); |
| // FIXME: Simplify these using optional CanvasWindingRule once crbug.com/339000 gets fixed. |
| void clip(); |
| [RuntimeEnabled=Path2D] void clip(Path2D path); |
| void clip(CanvasWindingRule winding); |
| [RuntimeEnabled=Path2D] void clip(Path2D path, CanvasWindingRule winding); |
| |
| // FIXME: Simplify these using optional CanvasWindingRule once crbug.com/339000 gets fixed. |
| boolean isPointInPath(unrestricted float x, unrestricted float y); |
| [RuntimeEnabled=Path2D] boolean isPointInPath(Path2D path, unrestricted float x, unrestricted float y); |
| boolean isPointInPath(unrestricted float x, unrestricted float y, CanvasWindingRule winding); |
| [RuntimeEnabled=Path2D] boolean isPointInPath(Path2D path, unrestricted float x, unrestricted float y, CanvasWindingRule winding); |
| boolean isPointInStroke(unrestricted float x, unrestricted float y); |
| [RuntimeEnabled=Path2D] boolean isPointInStroke(Path2D path, unrestricted float x, unrestricted float y); |
| |
| [RuntimeEnabled=ExperimentalCanvasFeatures] void scrollPathIntoView(); |
| [RuntimeEnabled=ExperimentalCanvasFeatures] void scrollPathIntoView(Path2D path); |
| |
| // text |
| attribute DOMString font; |
| attribute DOMString textAlign; |
| attribute DOMString textBaseline; |
| void fillText(DOMString text, unrestricted float x, unrestricted float y, optional unrestricted float maxWidth); |
| void strokeText(DOMString text, unrestricted float x, unrestricted float y, optional unrestricted float maxWidth); |
| |
| TextMetrics measureText(DOMString text); |
| |
| // Context state |
| // Should be merged with WebGL counterpart in CanvasRenderingContext, once no-longer experimental |
| [RuntimeEnabled=ExperimentalCanvasFeatures] boolean isContextLost(); |
| |
| void strokeRect(unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height); |
| |
| [RaisesException] void drawImage(HTMLImageElement image, unrestricted float x, unrestricted float y); |
| [RaisesException] void drawImage(HTMLImageElement image, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height); |
| [RaisesException] void drawImage(HTMLImageElement image, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh); |
| [RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted float x, unrestricted float y); |
| [RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height); |
| [RaisesException] void drawImage(HTMLCanvasElement canvas, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh); |
| [RaisesException] void drawImage(HTMLVideoElement video, unrestricted float x, unrestricted float y); |
| [RaisesException] void drawImage(HTMLVideoElement video, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height); |
| [RaisesException] void drawImage(HTMLVideoElement video, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh); |
| [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void drawImage(ImageBitmap imageBitmap, unrestricted float x, unrestricted float y); |
| [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void drawImage(ImageBitmap imageBitmap, unrestricted float x, unrestricted float y, unrestricted float width, unrestricted float height); |
| [RuntimeEnabled=ExperimentalCanvasFeatures, RaisesException] void drawImage(ImageBitmap imageBitmap, unrestricted float sx, unrestricted float sy, unrestricted float sw, unrestricted float sh, unrestricted float dx, unrestricted float dy, unrestricted float dw, unrestricted float dh); |
| |
| void putImageData(ImageData imagedata, float dx, float dy); |
| void putImageData(ImageData imagedata, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight); |
| |
| [RaisesException] CanvasPattern createPattern(HTMLCanvasElement canvas, [TreatNullAs=NullString] DOMString repetitionType); |
| [RaisesException] CanvasPattern createPattern(HTMLImageElement image, [TreatNullAs=NullString] DOMString repetitionType); |
| [RaisesException] CanvasPattern createPattern(HTMLVideoElement image, [TreatNullAs=NullString] DOMString repetitionType); |
| ImageData createImageData(ImageData imagedata); |
| [RaisesException] ImageData createImageData(float sw, float sh); |
| |
| [Custom] attribute object strokeStyle; |
| [Custom] attribute object fillStyle; |
| |
| // pixel manipulation |
| [RaisesException] ImageData getImageData(float sx, float sy, float sw, float sh); |
| |
| // Focus rings |
| [RuntimeEnabled=ExperimentalCanvasFeatures] void drawFocusIfNeeded(Element element); |
| [RuntimeEnabled=ExperimentalCanvasFeatures] void drawFocusIfNeeded(Path2D path, Element element); |
| [RuntimeEnabled=ExperimentalCanvasFeatures] boolean drawCustomFocusRing(Element element); |
| |
| [ImplementedAs=imageSmoothingEnabled, MeasureAs=PrefixedImageSmoothingEnabled] attribute boolean webkitImageSmoothingEnabled; |
| [MeasureAs=UnprefixedImageSmoothingEnabled] attribute boolean imageSmoothingEnabled; |
| |
| Canvas2DContextAttributes getContextAttributes(); |
| |
| // Non-standard APIs. Candidates for deprecation |
| [MeasureAs=CanvasRenderingContext2DSetAlpha] void setAlpha(unrestricted float alpha); |
| [MeasureAs=CanvasRenderingContext2DSetCompositeOperation] void setCompositeOperation(DOMString compositeOperation); |
| [MeasureAs=CanvasRenderingContext2DSetLineWidth] void setLineWidth(unrestricted float width); |
| [MeasureAs=CanvasRenderingContext2DSetLineCap] void setLineCap(DOMString cap); |
| [MeasureAs=CanvasRenderingContext2DSetLineJoin] void setLineJoin(DOMString join); |
| [MeasureAs=CanvasRenderingContext2DSetMiterLimit] void setMiterLimit(unrestricted float limit); |
| [MeasureAs=CanvasRenderingContext2DClearShadow] void clearShadow(); |
| [MeasureAs=CanvasRenderingContext2DSetStrokeColor] void setStrokeColor([LegacyOverloadString] DOMString color, optional unrestricted float alpha); |
| [MeasureAs=CanvasRenderingContext2DSetStrokeColor] void setStrokeColor(unrestricted float grayLevel, optional unrestricted float alpha); |
| [MeasureAs=CanvasRenderingContext2DSetStrokeColor] void setStrokeColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a); |
| [MeasureAs=CanvasRenderingContext2DSetStrokeColor] void setStrokeColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a); |
| [MeasureAs=CanvasRenderingContext2DSetFillColor] void setFillColor([LegacyOverloadString] DOMString color, optional unrestricted float alpha); |
| [MeasureAs=CanvasRenderingContext2DSetFillColor] void setFillColor(unrestricted float grayLevel, optional unrestricted float alpha); |
| [MeasureAs=CanvasRenderingContext2DSetFillColor] void setFillColor(unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a); |
| [MeasureAs=CanvasRenderingContext2DSetFillColor] void setFillColor(unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a); |
| [MeasureAs=CanvasRenderingContext2DDrawImageFromRect] void drawImageFromRect( |
| HTMLImageElement? image, optional unrestricted float sx, optional unrestricted float sy, optional unrestricted float sw, optional unrestricted float sh, |
| optional unrestricted float dx, optional unrestricted float dy, optional unrestricted float dw, optional unrestricted float dh, optional DOMString compositeOperation); |
| [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, [LegacyOverloadString] optional DOMString color, optional unrestricted float alpha); |
| [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float grayLevel, optional unrestricted float alpha); |
| [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float r, unrestricted float g, unrestricted float b, unrestricted float a); |
| [MeasureAs=CanvasRenderingContext2DSetShadow] void setShadow(unrestricted float width, unrestricted float height, unrestricted float blur, unrestricted float c, unrestricted float m, unrestricted float y, unrestricted float k, unrestricted float a); |
| }; |
| |
| CanvasRenderingContext2D implements CanvasPathMethods; |