/** * Draws an arc. If the context has a non-empty path, then the method must add a straight line * from the last point in the path to the start point of the arc. * * @param x center X coordinate * @param y center Y coordinate * @param radius radius of drawn arc * @param startAngle angle measured from positive X axis to start of arc CW * @param endAngle angle measured from positive X axis to end of arc CW * @param antiClockwise direction that the arc line is drawn */ public void arc( double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise) { impl.arc(x, y, radius, startAngle, endAngle, antiClockwise); }
/** * Draws an input image at a given position on the canvas. Resizes image according to specified * width and height and samples from the specified sourceY and sourceX. * * <p>We recommend that the pixel and coordinate spaces be the same to provide consistent * positioning and scaling results * * @param img the image to be drawn * @param sourceX the start X position in the source image * @param sourceY the start Y position in the source image * @param sourceWidth the width in the source image you want to sample * @param sourceHeight the height in the source image you want to sample * @param destX the start X position in the destination image * @param destY the start Y position in the destination image * @param destWidth the width of drawn image in the destination * @param destHeight the height of the drawn image in the destination */ public void drawImage( ImageElement img, double sourceX, double sourceY, double sourceWidth, double sourceHeight, double destX, double destY, double destWidth, double destHeight) { impl.drawImage( img, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight); }
/** * Applies a translation (linear shift) by x in the horizontal and by y in the vertical. * * @param x amount to shift in the x direction * @param y amount to shift in the y direction */ public void translate(double x, double y) { impl.translate(x, y); }
/** * Strokes a rectangle defined by the supplied arguments. * * @param startX x coord of the top left corner * @param startY y coord of the top left corner * @param width width of the rectangle * @param height height of the rectangle */ public void strokeRect(double startX, double startY, double width, double height) { impl.strokeRect(startX, startY, width, height); }
/** * Set the current Stroke Style to the specified color. * * @param color {@link Color} */ public void setStrokeStyle(Color color) { impl.setStrokeStyle(color.toString()); }
/** * Sets the CSS width in pixels for the canvas. * * @param width width of the canvas in pixels */ public void setPixelWidth(int width) { impl.setPixelWidth(getElement(), width); }
/** * A double value with the new miter limit. You use this property to specify how the canvas draws * the juncture between connected line segments. If the line join is set to <code>GWTCanvas.MITER * </code>, the canvas uses the miter limit to determine whether the lines should be joined with a * bevel instead of a miter. The canvas divides the length of the miter by the line width. If the * result is greater than the miter limit, the style is converted to a bevel. * * @param miterLimit */ public void setMiterLimit(double miterLimit) { impl.setMiterLimit(miterLimit); }
/** * A string value that determines the join style between lines. Specify the string <code> * GWTCanvas.ROUND</code> for round joins, <code>GWTCanvas.BEVEL</code> for beveled joins, or * <code>GWTCanvas.MITER</code> for miter joins. If you do not set this value explicitly, the * canvas uses the <code>GWTCanvas.MITER</code> line join style. * * @param lineJoin */ public void setLineJoin(String lineJoin) { impl.setLineJoin(lineJoin); }
/** Saves the current context to the context stack. */ public void saveContext() { impl.saveContext(); }
/** * Adds a rotation of the specified angle to the current transform. * * @param angle the angle to rotate by, <b>in radians</b> */ public void rotate(double angle) { impl.rotate(angle); }
/** Restores the last saved context from the context stack. */ public void restoreContext() { impl.restoreContext(); }
/** * Adds a rectangle to the current path, and closes the path. * * @param startX x coord of the top left corner of the rectangle * @param startY y coord of the top left corner of the rectangle * @param width the width of the rectangle * @param height the height of the rectangle */ public void rect(double startX, double startY, double width, double height) { impl.rect(startX, startY, width, height); }
/** * Does nothing if the context has an empty path. Otherwise it connects the last point in the path * to the given point <b>(x, y)</b> using a quadratic Bézier curve with control point <b>(cpx, * cpy)</b>, and then adds the given point <b>(x, y)</b> to the path. * * @param cpx x coord of the control point * @param cpy y coord of the control point * @param x x coord of the point * @param y y coord of the point */ public void quadraticCurveTo(double cpx, double cpy, double x, double y) { impl.quadraticCurveTo(cpx, cpy, x, y); }
/** * Makes the last point in the current path be <b>(x,y)</b>. * * @param x x coord of point * @param y y coord of point */ public void moveTo(double x, double y) { impl.moveTo(x, y); }
/** * Adds a line from the last point in the current path to the point defined by x and y. * * @param x x coord of point * @param y y coord of point */ public void lineTo(double x, double y) { impl.lineTo(x, y); }
/** * Determines how the canvas is displayed relative to any background content. The string * identifies the desired compositing mode. If you do not set this value explicitly, the canvas * uses the <code>GWTCanvas.SOURCE_OVER</code> compositing mode. * * <p>The valid compositing operators are: * * <ul> * <li><code>GWTCanvas.SOURCE_OVER</code> * <li><code>GWTCanvas.DESTINATION_OVER</code> * </ul> * * <p> * * @param globalCompositeOperation */ public void setGlobalCompositeOperation(String globalCompositeOperation) { impl.setGlobalCompositeOperation(globalCompositeOperation); }
/** * A string value that determines the end style used when drawing a line. Specify the string * <code>GWTCanvas.BUTT</code> for a flat edge that is perpendicular to the line itself, <code> * GWTCanvas.ROUND</code> for round endpoints, or <code>GWTCanvas.SQUARE</code> for square * endpoints. If you do not set this value explicitly, the canvas uses the <code>GWTCanvas.BUTT * </code> line cap style. * * @param lineCap */ public void setLineCap(String lineCap) { impl.setLineCap(lineCap); }
/** * Adds a scale transformation to the current transformation matrix. * * @param x ratio that we must scale in the X direction * @param y ratio that we must scale in the Y direction */ public void scale(double x, double y) { impl.scale(x, y); }
/** * Sets the current context's linewidth. Line width is the thickness of a stroked line. * * @param width the width of the canvas */ public void setLineWidth(double width) { impl.setLineWidth(width); }
/** * Sets the background color of the canvas element. * * @param color the background color. */ public void setBackgroundColor(Color color) { impl.setBackgroundColor(getElement(), color.toString()); }
/** * Sets the CSS height of the canvas in pixels. * * @param height the height of the canvas in pixels */ public void setPixelHeight(int height) { impl.setPixelHeight(getElement(), height); }
/** * Sets the coordinate height of the Canvas. * * <p>This will erase the canvas contents! * * @param height the size of the y component of the coordinate space */ public void setCoordHeight(int height) { impl.setCoordHeight(getElement(), height); coordHeight = height; }
/** * Set the current Stroke Style to the specified color gradient. * * <p>WARNING: Canvas Gradients currently have an unfinished implementation for Internet Explorer. * We would more than welcome a patch from the community to get gradients working on IE. * * @param grad {@link CanvasGradient} */ public void setStrokeStyle(CanvasGradient grad) { impl.setStrokeStyle(grad); }
/** * Sets the coordinate width of the Canvas. * * <p>This will erase the canvas contents! * * @param width the size of the x component of the coordinate space */ public void setCoordWidth(int width) { impl.setCoordWidth(getElement(), width); coordWidth = width; }
/** Strokes the current path according to the current stroke style. */ public void stroke() { impl.stroke(); }
/** * Set the current Fill Style to the specified color gradient. * * <p>WARNING: Canvas Gradients currently have an unfinished implementation for Internet Explorer. * We would more than welcome a patch from the community to get gradients working on IE. * * @param grad {@link CanvasGradient} */ public void setFillStyle(CanvasGradient grad) { impl.setFillStyle(grad); }
/** * <code>The transform(m11, m12, m21, m22, dx, dy)</code> method must multiply the current * transformation matrix with the input matrix. Input described by: * * <pre> * m11 m21 dx * m12 m22 dy * 0 0 1 * </pre> * * @param m11 top left cell of 2x2 rotation matrix * @param m12 top right cell of 2x2 rotation matrix * @param m21 bottom left cell of 2x2 rotation matrix * @param m22 bottom right cell of 2x2 rotation matrix * @param dx Translation in X direction * @param dy Translation in Y direction */ public void transform(double m11, double m12, double m21, double m22, double dx, double dy) { impl.transform(m11, m12, m21, m22, dx, dy); }
/** * Set the current Fill Style to the specified color. * * @param color {@link Color} */ public void setFillStyle(Color color) { impl.setFillStyle(color.toString()); }
/** * Creates a GWTCanvas element. Element type depends on deferred binding. Default is CANVAS HTML5 * DOM element. In the case of IE it should be VML. * * <p>Screen size of canvas in pixels defaults to <b>300x150</b> pixels. */ public GWTCanvas() { setElement(impl.createElement()); setPixelWidth(300); setPixelHeight(150); setCoordSize(300, 150); }
/** * Set the global transparency to the specified alpha. * * @param alpha alpha value */ public void setGlobalAlpha(double alpha) { impl.setGlobalAlpha(alpha); }