CanvasRenderingContext2D.hx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * Copyright (C)2005-2013 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. // This file is generated, do not edit!
  23. package js.html;
  24. /** The bulk of the operations available at present with <code><a rel="custom" href="https://developer.mozilla.org/en/HTML/Element/canvas">&lt;canvas&gt;</a></code>
  25. are available through this interface, returned by a call to <code>getContext()</code> on the <code><a rel="custom" href="https://developer.mozilla.org/en/HTML/Element/canvas">&lt;canvas&gt;</a></code>
  26. element, with "2d" as its argument.<br><br>
  27. Documentation for this class was provided by <a href="https://developer.mozilla.org/en/DOM/CanvasRenderingContext2D">MDN</a>. */
  28. @:native("CanvasRenderingContext2D")
  29. extern class CanvasRenderingContext2D extends CanvasRenderingContext
  30. {
  31. var backingStorePixelRatio(default,null) : Float;
  32. /** Color or style to use inside shapes. Default <code>#000</code> (black). */
  33. var fillStyle : Dynamic;
  34. /** Default value <code>10px sans-serif</code>. */
  35. var font : String;
  36. /** Alpha value that is applied to shapes and images before they are composited onto the canvas. Default <code>1.0</code> (opaque). */
  37. var globalAlpha : Float;
  38. /** With <code>globalAplpha</code> applied this sets how shapes and images are drawn onto the existing bitmap. Possible values: <ul> <li><code>source-atop</code></li> <li><code>source-in</code></li> <li><code>source-out</code></li> <li><code>source-over</code> (default)</li> <li><code>destination-atop</code></li> <li><code>destination-in</code></li> <li><code>destination-out</code></li> <li><code>destination-over</code></li> <li><code>lighter</code></li> <li><code>xor</code></li> </ul> */
  39. var globalCompositeOperation : String;
  40. var imageSmoothingEnabled : Bool;
  41. /** Type of endings on the end of lines. Possible values: <code>butt</code> (default), <code>round</code>, <code>square</code> */
  42. var lineCap : String;
  43. var lineDash : Array<Dynamic>;
  44. var lineDashOffset : Float;
  45. /** Defines the type of corners where two lines meet. Possible values: <code>round</code>, <code>bevel</code>, <code>miter</code> (default) */
  46. var lineJoin : String;
  47. /** Width of lines. Default <code>1.0</code> */
  48. var lineWidth : Float;
  49. /** Default <code>10</code>. */
  50. var miterLimit : Float;
  51. /** Specifies the blurring effect. Default <code>0</code> */
  52. var shadowBlur : Float;
  53. /** Color of the shadow. Default fully-transparent black. */
  54. var shadowColor : String;
  55. /** Horizontal distance the shadow will be offset. Default 0. */
  56. var shadowOffsetX : Float;
  57. /** Vertical distance the shadow will be offset. Default 0. */
  58. var shadowOffsetY : Float;
  59. /** Color or style to use for the lines around shapes. Default <code>#000</code> (black). */
  60. var strokeStyle : Dynamic;
  61. /** Possible values: <code>start</code> (default), <code>end</code>, <code>left</code>, <code>right</code> or <code>center</code>. */
  62. var textAlign : String;
  63. var textBaseline : String;
  64. function arc( x : Float, y : Float, radius : Float, startAngle : Float, endAngle : Float, anticlockwise : Bool ) : Void;
  65. function arcTo( x1 : Float, y1 : Float, x2 : Float, y2 : Float, radius : Float ) : Void;
  66. function beginPath() : Void;
  67. function bezierCurveTo( cp1x : Float, cp1y : Float, cp2x : Float, cp2y : Float, x : Float, y : Float ) : Void;
  68. function clearRect( x : Float, y : Float, width : Float, height : Float ) : Void;
  69. function clearShadow() : Void;
  70. function clip() : Void;
  71. function closePath() : Void;
  72. /** Throws DOMException. */
  73. @:overload( function( imagedata : ImageData ) :ImageData {} )
  74. function createImageData( sw : Float, sh : Float ) : ImageData;
  75. function createLinearGradient( x0 : Float, y0 : Float, x1 : Float, y1 : Float ) : CanvasGradient;
  76. /** <div id="section_31"><span id="Parameters_10"></span><h6 class="editable">Parameters</h6>
  77. <dl> <dt><code>image</code></dt> <dd>A DOM <code><a rel="custom" href="https://developer.mozilla.org/en/DOM/element">element</a></code>
  78. to use as the source image for the pattern. This can be any element, although typically you'll use an <code><a rel="internal" href="https://developer.mozilla.org/Article_not_found?uri=en/DOM/Image" class="new">Image</a></code>
  79. or <code><a rel="custom" href="https://developer.mozilla.org/en/HTML/Element/canvas">&lt;canvas&gt;</a></code>
  80. .</dd> <dt><code>repetition</code></dt> <dd>?</dd>
  81. </dl>
  82. </div><div id="section_32"><span id="Return_value_3"></span><h6 class="editable">Return value</h6>
  83. <p>A new DOM canvas pattern object for use in pattern-based operations.</p>
  84. </div><div id="section_33"><span id="Exceptions_thrown"></span><h6 class="editable">Exceptions thrown</h6>
  85. <dl> <dt><code>NS_ERROR_DOM_INVALID_STATE_ERR</code>
  86. <span title="(Firefox 10.0 / Thunderbird 10.0)
  87. ">Requires Gecko 10.0</span>
  88. </dt> <dd>The specified <code><a rel="custom" href="https://developer.mozilla.org/en/HTML/Element/canvas">&lt;canvas&gt;</a></code>
  89. element for the <code>image</code> parameter is zero-sized (that is, one or both of its dimensions are 0 pixels).</dd>
  90. </dl>
  91. </div> Throws DOMException. */
  92. @:overload( function( canvas : CanvasElement, repetitionType : String ) :CanvasPattern {} )
  93. function createPattern( image : ImageElement, repetitionType : String ) : CanvasPattern;
  94. function createRadialGradient( x0 : Float, y0 : Float, r0 : Float, x1 : Float, y1 : Float, r1 : Float ) : CanvasGradient;
  95. /** <p>Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in its use.</p>
  96. <div id="section_41"><span id="Parameters_13"></span><h6 class="editable">Parameters</h6>
  97. <dl> <dt><code>image</code></dt> <dd>An element to draw into the context; the specification permits any image element (that is, <code><a rel="custom" href="https://developer.mozilla.org/en/HTML/Element/img">&lt;img&gt;</a></code>
  98. , <code><a rel="custom" href="https://developer.mozilla.org/en/HTML/Element/canvas">&lt;canvas&gt;</a></code>
  99. , and <code><a rel="custom" href="https://developer.mozilla.org/en/HTML/Element/video">&lt;video&gt;</a></code>
  100. ). Some browsers, including Firefox, let you use any arbitrary element.</dd> <dt><code>dx</code></dt> <dd>The X coordinate in the destination canvas at which to place the top-left corner of the source <code>image</code>.</dd> <dt><code>dy</code></dt> <dd>The Y coordinate in the destination canvas at which to place the top-left corner of the source <code>image</code>.</dd> <dt><code>dw</code></dt> <dd>The width to draw the <code>image</code> in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.</dd> <dt><code>dh</code></dt> <dd>The height to draw the <code>image</code> in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.</dd> <dt><code>sx</code></dt> <dd>The X coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.</dd> <dt><code>sy</code></dt> <dd>The Y coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.</dd> <dt><code>sw</code></dt> <dd>The width of the sub-rectangle of the source image to draw into the destination context. If not specified, the entire rectangle from the coordinates specified by <code>sx</code> and <code>sy</code> to the bottom-right corner of the image is used. If you specify a negative value, the image is flipped horizontally when drawn.</dd> <dt><code>sh</code></dt> <dd>The height of the sub-rectangle of the source image to draw into the destination context. If you specify a negative value, the image is flipped vertically when drawn.</dd>
  101. </dl>
  102. <p>The diagram below illustrates the meanings of the various parameters.</p>
  103. <p><img alt="drawImage.png" class="internal default" src="https://developer.mozilla.org/@api/deki/files/5494/=drawImage.png"></p>
  104. </div><div id="section_42"><span id="Exceptions_thrown_2"></span><h6 class="editable">Exceptions thrown</h6>
  105. <dl> <dt><code>INDEX_SIZE_ERR</code></dt> <dd>If the canvas or source rectangle width or height is zero.</dd> <dt><code>INVALID_STATE_ERR</code></dt> <dd>The image has no image data.</dd> <dt><code>TYPE_MISMATCH_ERR</code></dt> <dd>The specified source element isn't supported. This is not thrown by Firefox, since any element may be used as a source image.</dd>
  106. </dl>
  107. </div><div id="section_43"><span id="Compatibility_notes"></span><h6 class="editable">Compatibility notes</h6>
  108. <ul> <li>Prior to Gecko 7.0 (Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4)
  109. , Firefox threw an exception if any of the coordinate values was non-finite or zero. As per the specification, this no longer happens.</li> <li>Support for flipping the image by using negative values for <code>sw</code> and <code>sh</code> was added in Gecko 5.0 (Firefox 5.0 / Thunderbird 5.0 / SeaMonkey 2.2)
  110. .</li> <li>Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6)
  111. now correctly supports CORS for drawing images across domains without <a title="en/CORS_Enabled_Image#What_is_a_.22tainted.22_canvas.3F" rel="internal" href="https://developer.mozilla.org/en/CORS_Enabled_Image#What_is_a_.22tainted.22_canvas.3F">tainting the canvas</a>.</li>
  112. </ul>
  113. </div> Throws DOMException. */
  114. @:overload( function( image : ImageElement, x : Float, y : Float ) :Void {} )
  115. @:overload( function( image : ImageElement, x : Float, y : Float, width : Float, height : Float ) :Void {} )
  116. @:overload( function( image : ImageElement, sx : Float, sy : Float, sw : Float, sh : Float, dx : Float, dy : Float, dw : Float, dh : Float ) :Void {} )
  117. @:overload( function( canvas : CanvasElement, x : Float, y : Float ) :Void {} )
  118. @:overload( function( canvas : CanvasElement, x : Float, y : Float, width : Float, height : Float ) :Void {} )
  119. @:overload( function( canvas : CanvasElement, sx : Float, sy : Float, sw : Float, sh : Float, dx : Float, dy : Float, dw : Float, dh : Float ) :Void {} )
  120. @:overload( function( video : VideoElement, x : Float, y : Float ) :Void {} )
  121. @:overload( function( video : VideoElement, x : Float, y : Float, width : Float, height : Float ) :Void {} )
  122. function drawImage( video : VideoElement, sx : Float, sy : Float, sw : Float, sh : Float, dx : Float, dy : Float, dw : Float, dh : Float ) : Void;
  123. function drawImageFromRect( image : ImageElement, ?sx : Float, ?sy : Float, ?sw : Float, ?sh : Float, ?dx : Float, ?dy : Float, ?dw : Float, ?dh : Float, ?compositeOperation : String ) : Void;
  124. function fill() : Void;
  125. function fillRect( x : Float, y : Float, width : Float, height : Float ) : Void;
  126. function fillText( text : String, x : Float, y : Float, ?maxWidth : Float ) : Void;
  127. function getImageData( sx : Float, sy : Float, sw : Float, sh : Float ) : ImageData;
  128. function getImageDataHD( sx : Float, sy : Float, sw : Float, sh : Float ) : ImageData;
  129. function getLineDash() : Array<Float>;
  130. function isPointInPath( x : Float, y : Float ) : Bool;
  131. function lineTo( x : Float, y : Float ) : Void;
  132. function measureText( text : String ) : TextMetrics;
  133. function moveTo( x : Float, y : Float ) : Void;
  134. /** <h6 class="editable">Compatibility notes</h6>
  135. <ul> <li>Starting in Gecko 10.0 (Firefox 10.0 / Thunderbird 10.0)
  136. , non-finite values to any of these parameters causes the call to putImageData() to be silently ignored, rather than throwing an exception.</li>
  137. </ul> Throws DOMException. */
  138. @:overload( function( imagedata : ImageData, dx : Float, dy : Float ) :Void {} )
  139. function putImageData( imagedata : ImageData, dx : Float, dy : Float, dirtyX : Float, dirtyY : Float, dirtyWidth : Float, dirtyHeight : Float ) : Void;
  140. /** Throws DOMException. */
  141. @:overload( function( imagedata : ImageData, dx : Float, dy : Float ) :Void {} )
  142. function putImageDataHD( imagedata : ImageData, dx : Float, dy : Float, dirtyX : Float, dirtyY : Float, dirtyWidth : Float, dirtyHeight : Float ) : Void;
  143. function quadraticCurveTo( cpx : Float, cpy : Float, x : Float, y : Float ) : Void;
  144. function rect( x : Float, y : Float, width : Float, height : Float ) : Void;
  145. function restore() : Void;
  146. function rotate( angle : Float ) : Void;
  147. function save() : Void;
  148. function scale( sx : Float, sy : Float ) : Void;
  149. function setAlpha( alpha : Float ) : Void;
  150. function setCompositeOperation( compositeOperation : String ) : Void;
  151. @:overload( function( color : String, ?alpha : Float ) :Void {} )
  152. @:overload( function( grayLevel : Float, ?alpha : Float ) :Void {} )
  153. @:overload( function( r : Float, g : Float, b : Float, a : Float ) :Void {} )
  154. function setFillColor( c : Float, m : Float, y : Float, k : Float, a : Float ) : Void;
  155. function setLineCap( cap : String ) : Void;
  156. function setLineDash( dash : Array<Float> ) : Void;
  157. function setLineJoin( join : String ) : Void;
  158. function setLineWidth( width : Float ) : Void;
  159. function setMiterLimit( limit : Float ) : Void;
  160. @:overload( function( width : Float, height : Float, blur : Float, ?color : String, ?alpha : Float ) :Void {} )
  161. @:overload( function( width : Float, height : Float, blur : Float, grayLevel : Float, ?alpha : Float ) :Void {} )
  162. @:overload( function( width : Float, height : Float, blur : Float, r : Float, g : Float, b : Float, a : Float ) :Void {} )
  163. function setShadow( width : Float, height : Float, blur : Float, c : Float, m : Float, y : Float, k : Float, a : Float ) : Void;
  164. @:overload( function( color : String, ?alpha : Float ) :Void {} )
  165. @:overload( function( grayLevel : Float, ?alpha : Float ) :Void {} )
  166. @:overload( function( r : Float, g : Float, b : Float, a : Float ) :Void {} )
  167. function setStrokeColor( c : Float, m : Float, y : Float, k : Float, a : Float ) : Void;
  168. function setTransform( m11 : Float, m12 : Float, m21 : Float, m22 : Float, dx : Float, dy : Float ) : Void;
  169. function stroke() : Void;
  170. function strokeRect( x : Float, y : Float, width : Float, height : Float, ?lineWidth : Float ) : Void;
  171. function strokeText( text : String, x : Float, y : Float, ?maxWidth : Float ) : Void;
  172. function transform( m11 : Float, m12 : Float, m21 : Float, m22 : Float, dx : Float, dy : Float ) : Void;
  173. function translate( tx : Float, ty : Float ) : Void;
  174. }