Class CanvasElement

    • Field Detail

      • TAG

        public static final java.lang.String TAG
        The tag for this element.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CanvasElement

        protected CanvasElement()
    • Method Detail

      • getContext

        public final Context getContext​(java.lang.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
      • getContext2d

        public final Context2d getContext2d()
        Returns a 2D rendering context. This is a convenience method, see getContext(String).
        Returns:
        a 2D canvas rendering context
      • getHeight

        public final int getHeight()
        Gets the height of the canvas.
        Returns:
        the height, in pixels
        See Also:
        setHeight(int)
      • getWidth

        public final int getWidth()
        Gets the width of the canvas.
        Returns:
        the width, in pixels
        See Also:
        setWidth(int)
      • setHeight

        public final void setHeight​(int height)
        Sets the height of the canvas.
        Parameters:
        height - the height, in pixels
        See Also:
        getHeight()
      • setWidth

        public final void setWidth​(int width)
        Sets the width of the canvas.
        Parameters:
        width - the width, in pixels
        See Also:
        getWidth()
      • toDataUrl

        public final java.lang.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.
      • toDataUrl

        public final java.lang.String toDataUrl​(java.lang.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.