Back to index

lightning-sunbird  0.9+nobinonly
nsIDOMCanvasRenderingContext2D.idl
Go to the documentation of this file.
00001 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  *   Vladimir Vukicevic <vladimir@pobox.com>
00019  * Portions created by the Initial Developer are Copyright (C) 2005
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "nsISupports.idl"
00039 #include "nsIVariant.idl"
00040 
00041 interface nsIDOMWindow;
00042 interface nsIDOMHTMLElement;
00043 interface nsIDOMHTMLImageElement;
00044 interface nsIDOMHTMLCanvasElement;
00045 
00046 [scriptable, uuid(bbb20a59-524e-4662-981e-5e142814b20c)]
00047 interface nsIDOMCanvasGradient : nsISupports
00048 {
00049   void addColorStop(in float offset, in DOMString color);
00050 };
00051 
00052 [scriptable, uuid(21dea65c-5c08-4eb1-ac82-81fe95be77b8)]
00053 interface nsIDOMCanvasPattern : nsISupports
00054 {
00055 };
00056 
00057 [scriptable, uuid(ab27f42d-e1e1-4ef6-9c83-059a81da479b)]
00058 interface nsIDOMCanvasRenderingContext2D : nsISupports
00059 {
00060   // back-reference to the canvas element for which
00061   // this context was created
00062   readonly attribute nsIDOMHTMLCanvasElement canvas;
00063 
00064   // state
00065   void save();
00066   void restore();
00067 
00068   // transformations
00069   void scale(in float x, in float y);
00070   void rotate(in float angle);
00071   void translate(in float x, in float y);
00072 
00073   // compositing
00074   attribute float globalAlpha; /* default 1.0 -- opaque */
00075   attribute DOMString globalCompositeOperation; /* default "over" */
00076 
00077   // colors and styles
00078   attribute nsIVariant strokeStyle;
00079   attribute nsIVariant fillStyle;
00080 
00081   nsIDOMCanvasGradient createLinearGradient (in float x0, in float y0, in float x1, in float y1);
00082   nsIDOMCanvasGradient createRadialGradient(in float x0, in float y0, in float r0, in float x1, in float y1, in float r1);
00083   //nsIDOMCanvasPattern createPattern(in nsIDOMHTMLImageElement image, in DOMString repetition);
00084   nsIDOMCanvasPattern createPattern(in nsIDOMHTMLElement image, in DOMString repetition);
00085   attribute float lineWidth; /* default 1 */
00086   attribute DOMString lineCap; /* "butt", "round", "square" (default) */
00087   attribute DOMString lineJoin; /* "round", "bevel", "miter" (default) */
00088   attribute float miterLimit; /* default 10 */
00089 
00090   // shadows
00091   attribute float shadowOffsetX;
00092   attribute float shadowOffsetY;
00093   attribute float shadowBlur;
00094   attribute DOMString shadowColor;
00095 
00096   // rects
00097   void clearRect(in float x, in float y, in float w, in float h);
00098   void fillRect(in float x, in float y, in float w, in float h);
00099   void strokeRect(in float x, in float y, in float w, in float h);
00100 
00101   // path API
00102   void beginPath();
00103   void closePath();
00104 
00105   void moveTo(in float x, in float y);
00106   void lineTo(in float x, in float y);
00107   void quadraticCurveTo(in float cpx, in float cpy, in float x, in float y);
00108   void bezierCurveTo(in float cp1x, in float cp1y, in float cp2x, in float cp2y, in float x, in float y);
00109   void arcTo(in float x1, in float y1, in float x2, in float y2, in float radius);
00110   void arc(in float x, in float y, in float r, in float startAngle, in float endAngle, in boolean clockwise);
00111   void rect(in float x, in float y, in float w, in float h);
00112 
00113   void fill();
00114   void stroke();
00115   void clip();
00116 
00117   // image api
00118   void drawImage();
00119 /*
00120   void drawImage(in HTMLImageElement image, in float dx, in float dy);
00121   void drawImage(in HTMLImageElement image, in float dx, in float dy, in float sw, in float sh);
00122   void drawImage(in HTMLImageElement image, in float sx, in float sy, in float sw, in float sh, in float dx, in float dy, in float dw, in float dh);
00123 */
00124 
00125   // point-membership test
00126   boolean isPointInPath(in float x, in float y);
00127 
00128   // pixel manipulation
00129   // ImageData getImageData (in float x, in float y, in float width, in float height);
00130   // void putImageData (in ImageData d, in float x, in float y);
00131   // ImageData = { width: #, height: #, data: [r, g, b, a, ...] }
00132 
00133   void getImageData();
00134   void putImageData();
00135 
00168   void drawWindow(in nsIDOMWindow window, in long x, in long y,
00169                   in long w, in long h, in DOMString bgColor);
00170 };