Class Canvas
- java.lang.Object
-
- org.pepstock.charba.client.dom.BaseEventTarget
-
- org.pepstock.charba.client.dom.BaseNode
-
- org.pepstock.charba.client.dom.BaseElement
-
- org.pepstock.charba.client.dom.BaseHtmlElement
-
- org.pepstock.charba.client.dom.elements.Canvas
-
- All Implemented Interfaces:
IsJSType
,IsCastable
@JsType(isNative=true, name="HTMLCanvasElement", namespace="<global>") public final class Canvas extends BaseHtmlElement implements IsCastable
Represents a DOM element that enables drawing graphics and animations with own the canvas scripting API.- Author:
- Andrea "Stock" Stocchero
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.pepstock.charba.client.dom.BaseEventTarget
BaseEventTarget.EventListenerCallback
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_ENCODER_OPTIONS
static String
TAG
The tag for this element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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()
Returnstrue
if canvas is supported by browser, otherwisefalse
.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.-
Methods inherited from class org.pepstock.charba.client.dom.BaseHtmlElement
blur, focus, getAbsoluteLeft, getAbsoluteTop, getInnerText, getOffsetHeight, getOffsetLeft, getOffsetParent, getOffsetTop, getOffsetWidth, getParentHtmlElement, getScrollingElement, getStyle, getTabIndex, removeFromParent, setInnerText, setTabIndex
-
Methods inherited from class org.pepstock.charba.client.dom.BaseElement
getAttributes, getBoundingClientRect, getChildElementCount, getClientHeight, getClientLeft, getClientTop, getClientWidth, getElementsByTagName, getFirstElementChild, getId, getInnerHTML, getLastElementChild, getNextElementSibling, getOuterHTML, getPreviousElementSibling, getScrollHeight, getScrollLeft, getScrollTop, getScrollWidth, getTagName, hasAttributes, hasPointerCapture, releasePointerCapture, remove, setId, setInnerHTML, setPointerCapture
-
Methods inherited from class org.pepstock.charba.client.dom.BaseNode
appendChild, cloneNode, getChildNodes, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPreviousSibling, getTextContent, hasChildNodes, insertBefore, removeAllChildren, removeChild, setNodeValue, setTextContent
-
Methods inherited from class org.pepstock.charba.client.dom.BaseEventTarget
addEventListener, addEventListener, dispatchEvent, dispatchEvent, removeEventListener, removeEventListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pepstock.charba.client.dom.IsCastable
as
-
-
-
-
Field Detail
-
TAG
@JsOverlay public static final String TAG
The tag for this element.- See Also:
- Constant Field Values
-
DEFAULT_ENCODER_OPTIONS
@JsOverlay public static final double DEFAULT_ENCODER_OPTIONS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getHeight
@JsProperty public 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.- Returns:
- a positive integer reflecting the height HTML attribute of the canvas element interpreted in CSS pixels
-
setHeight
@JsProperty public 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.- Parameters:
height
- a positive integer reflecting the height HTML attribute of the canvas element interpreted in CSS pixels
-
getWidth
@JsProperty public 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.- Returns:
- a positive integer reflecting the width HTML attribute of the canvas element interpreted in CSS pixels
-
setWidth
@JsProperty public 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.- Parameters:
width
- a positive integer reflecting the width HTML attribute of the canvas element interpreted in CSS pixels
-
getContext2d
@JsOverlay public final Context2dItem getContext2d()
Returns a drawing 2D context on the canvas.- Returns:
- a drawing 2D context on the canvas
-
isSupported
@JsOverlay public final boolean isSupported()
Returnstrue
if canvas is supported by browser, otherwisefalse
.- Returns:
true
if canvas is supported by browser, otherwisefalse
-
toDataURL
@JsOverlay public final String toDataURL()
Returns a data-URL containing a representation of the image in the PNG format and the image quality value is 0.92.- Returns:
- a data-URL containing a representation of the image in the PNG format
-
toDataURL
@JsOverlay public final 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.- Parameters:
encoderOptions
- between 0 and 1 indicating the image quality to use for image formats that use lossy compression.
If this argument is anything else, the default value for image quality is used. The default value is 0.92.- Returns:
- a data-URL containing a representation of the image in the PNG format
-
toDataURL
@JsOverlay public final 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.- Parameters:
type
- indicating the image format- Returns:
- a data-URL containing a representation of the image format, passed as argument
-
toDataURL
@JsOverlay public final 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.- Parameters:
type
- indicating the image formatencoderOptions
- between 0 and 1 indicating the image quality to use for image formats that use lossy compression.
If this argument is anything else, the default value for image quality is used. The default value is 0.92.- Returns:
- a data-URL containing a representation of the image format, passed as argument
-
-