public class

CanvasElement

extends Element
java.lang.Object
   ↳ com.google.gwt.core.client.JavaScriptObject
     ↳ com.google.gwt.dom.client.Node
       ↳ com.google.gwt.dom.client.Element
         ↳ com.google.gwt.dom.client.CanvasElement

Class Overview

Canvas element.

Experimental API: This API is still under development and is subject to change.

Summary

Constants
String TAG The tag for this element.
[Expand]
Inherited Constants
From class com.google.gwt.dom.client.Node
Protected Constructors
CanvasElement()
Public Methods
final Context getContext(String contextId)
Gets the rendering context that may be used to draw on this canvas.
final Context2d getContext2d()
Returns a 2D rendering context.
final int getHeight()
Gets the height of the canvas.
final int getWidth()
Gets the width of the canvas.
final void setHeight(int height)
Sets the height of the canvas.
final void setWidth(int width)
Sets the width of the canvas.
final String toDataUrl()
Returns a data URL for the current content of the canvas element.
final String toDataUrl(String type)
Returns a data URL for the current content of the canvas element, with a specified type.
[Expand]
Inherited Methods
From class com.google.gwt.dom.client.Element
From class com.google.gwt.dom.client.Node
From class com.google.gwt.core.client.JavaScriptObject
From class java.lang.Object

Constants

public static final String TAG

The tag for this element.

Constant Value: "canvas"

Protected Constructors

protected CanvasElement ()

Public Methods

public final Context getContext (String contextId)

Gets the rendering context that may be used to draw on this canvas.

Parameters
contextId the context id as a String
Returns
  • the canvas rendering context

public final Context2d getContext2d ()

Returns a 2D rendering context. This is a convenience method, see getContext(String).

Returns
  • a 2D canvas rendering context

public final int getHeight ()

Gets the height of the canvas.

Returns
  • the height, in pixels
See Also

public final int getWidth ()

Gets the width of the canvas.

Returns
  • the width, in pixels
See Also

public final void setHeight (int height)

Sets the height of the canvas.

Parameters
height the height, in pixels
See Also

public final void setWidth (int width)

Sets the width of the canvas.

Parameters
width the width, in pixels
See Also

public final String toDataUrl ()

Returns a data URL for the current content of the canvas element.

Returns
  • a data URL for the current content of this element.

public final String toDataUrl (String type)

Returns a data URL for the current content of the canvas element, with a specified type.

Parameters
type the type of the data url, e.g., image/jpeg or image/png.
Returns
  • a data URL for the current content of this element with the specified type.