@JsType(isNative=true, name="HTMLCanvasElement", namespace="<global>") public final class Canvas extends BaseHtmlElement implements IsCastable
BaseEventTarget.EventListenerCallback
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_ENCODER_OPTIONS |
static String |
TAG
The tag for this element.
|
Modifier and Type | Method and Description |
---|---|
Context2dItem |
getContext2d()
Returns a drawing 2D context on the canvas.
|
int |
getHeight()
Returns a positive integer reflecting the height HTML attribute of the canvas element interpreted in CSS pixels.
When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 150 is used. |
int |
getWidth()
Returns a positive integer reflecting the width HTML attribute of the canvas element interpreted in CSS pixels.
When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 300 is used. |
boolean |
isSupported()
Returns
true if canvas is supported by browser, otherwise false . |
void |
setHeight(int height)
Sets a positive integer reflecting the height HTML attribute of the canvas element interpreted in CSS pixels.
When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 150 is used. |
void |
setWidth(int width)
Sets a positive integer reflecting the width HTML attribute of the canvas element interpreted in CSS pixels.
When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 300 is used. |
String |
toDataURL()
Returns a data-URL containing a representation of the image in the PNG format and the image quality value is 0.92.
|
String |
toDataURL(double encoderOptions)
Returns a data-URL containing a representation of the image in the PNG format.
The returned image is in a resolution of 96dpi. |
String |
toDataURL(ImageMimeType type)
Returns a data-URL containing a representation of the image format, passed as argument.
The returned image is in a resolution of 96dpi and the image quality value is 0.92. |
String |
toDataURL(ImageMimeType type,
double encoderOptions)
Returns a data-URL containing a representation of the image format, passed as argument.
The returned image is in a resolution of 96dpi. |
getAbsoluteLeft, getAbsoluteTop, getInnerText, getOffsetHeight, getOffsetLeft, getOffsetParent, getOffsetTop, getOffsetWidth, getParentHtmlElement, getScrollingElement, getStyle, getTabIndex, removeFromParent, setInnerText, setTabIndex
getAttributes, getChildElementCount, getClientHeight, getClientLeft, getClientTop, getClientWidth, getElementsByTagName, getFirstElementChild, getId, getInnerHTML, getLastElementChild, getNextElementSibling, getOuterHTML, getPreviousElementSibling, getScrollHeight, getScrollLeft, getScrollTop, getScrollWidth, getTagName, hasAttributes, remove, setId, setInnerHTML
appendChild, cloneNode, getChildNodes, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPreviousSibling, getTextContent, hasChildNodes, insertBefore, removeAllChildren, removeChild, setNodeValue, setTextContent
addEventListener, removeEventListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
as
@JsOverlay public static final String TAG
@JsOverlay public static final double DEFAULT_ENCODER_OPTIONS
@JsProperty public int getHeight()
@JsProperty public void setHeight(int height)
height
- a positive integer reflecting the height HTML attribute of the canvas element interpreted in CSS pixels@JsProperty public int getWidth()
@JsProperty public void setWidth(int width)
width
- a positive integer reflecting the width HTML attribute of the canvas element interpreted in CSS pixels@JsOverlay public final Context2dItem getContext2d()
@JsOverlay public final boolean isSupported()
true
if canvas is supported by browser, otherwise false
.true
if canvas is supported by browser, otherwise false
@JsOverlay public final String toDataURL()
@JsOverlay public final String toDataURL(double encoderOptions)
encoderOptions
- between 0 and 1 indicating the image quality to use for image formats that use lossy compression.@JsOverlay public final String toDataURL(ImageMimeType type)
type
- indicating the image format@JsOverlay public final String toDataURL(ImageMimeType type, double encoderOptions)
type
- indicating the image formatencoderOptions
- between 0 and 1 indicating the image quality to use for image formats that use lossy compression.