Interface CanvasElement
- All Superinterfaces:
DomQueryable,Element,EventTarget,Node
Canvases are rendered by displaying each pixel as its own TextDisplay
entity. Thus, when using a canvas element, keep in mind the amount of entities that will be used
to render the canvas.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault size of a canvas elementstatic final intMaximum allowed size for a canvas.static final intMinimum allowed size for a canvas -
Method Summary
Modifier and TypeMethodDescriptionbooleanCanvas elements cannot have any child nodes.@NotNull CanvasGet the canvas of this element.intGet the value of theAttributes.HEIGHTattribute.intgetWidth()Get the value of theAttributes.WIDTHattribute.voidsetHeight(int height) Set the value ofAttributes.HEIGHTattribute.voidsetWidth(int width) Set the value ofAttributes.WIDTHattribute.Methods inherited from interface com.juliewoolie.dom.DomQueryable
getElementsByClassName, getElementsByTagName, querySelector, querySelectorAllMethods inherited from interface com.juliewoolie.dom.Element
appendChild, appendElement, appendText, clearChildren, firstChild, forEachDescendant, getAttribute, getAttributeEntries, getAttributeNames, getChild, getChildCount, getChildren, getClassList, getClassName, getCurrentStyle, getId, getStyle, getTagName, getTextContent, getTitleNode, getTooltip, getTooltipBehaviour, getTooltipDelay, hasAttribute, hasChild, hasChildren, indexOf, insertAfter, insertBefore, isDescendant, lastChild, matches, prependChild, removeAttribute, removeChild, removeChild, removeMatchingChildren, replaceChild, replaceChild, setAttribute, setClassName, setId, setTextContent, setTitleNode, setTooltipBehaviour, setTooltipDelayMethods inherited from interface com.juliewoolie.dom.event.EventTarget
addEventListener, dispatchEvent, getOnAddAttribute, getOnAddOption, getOnAppendChild, getOnAttributeChange, getOnClick, getOnClosing, getOnInput, getOnLoaded, getOnMouseEnter, getOnMouseExit, getOnMouseMove, getOnOptionChange, getOnRemoveAttribute, getOnRemoveChild, getOnRemoveOption, getOnRightClick, getOnSetAttribute, getOnSetOption, getOnSpawned, onAddAttribute, onAddOption, onAppendChild, onAttributeChange, onClick, onClosing, onInput, onLoaded, onMouseEnter, onMouseExit, onMouseMove, onOptionChange, onRemoveAttribute, onRemoveChild, onRemoveOption, onRightClick, onSetAttribute, onSetOption, onSpawned, removeEventListenerMethods inherited from interface com.juliewoolie.dom.Node
enterVisitor, exitVisitor, getDepth, getOwningDocument, getParent, getRenderingBounds, getSiblingIndex, hasFlag, nextSibling, previousSibling
-
Field Details
-
MIN_SIZE
static final int MIN_SIZEMinimum allowed size for a canvas- See Also:
-
MAX_SIZE
static final int MAX_SIZEMaximum allowed size for a canvas.- See Also:
-
DEFAULT_SIZE
static final int DEFAULT_SIZEDefault size of a canvas element- See Also:
-
-
Method Details
-
canHaveChildren
@Contract("-> false") boolean canHaveChildren()Canvas elements cannot have any child nodes.- Specified by:
canHaveChildrenin interfaceElement- Returns:
false
-
getWidth
int getWidth()Get the value of theAttributes.WIDTHattribute.If the attribute has no value, or is not a valid number,
DEFAULT_SIZEis returned.Note: There is a brief window of time when the value returned by this method differs from
getCanvas()'sCanvas.getWidth(). This happens when the attribute is changed, as canvas is updated after all attribute change listeners have been called.- Returns:
- Width
-
setWidth
Set the value ofAttributes.WIDTHattribute.When called, the
getCanvas()'sCanvas.getWidth()will not be updated instantly. All attribute update listeners will be called first, then the canvas' size will be updated.When a canvas' size is changed, the canvas is resized, and any existing image data is retained, but the image will be cropped if the size is changed to smaller value than it was before.
- Parameters:
width- New width- Throws:
IllegalArgumentException- Ifwidthis less thanMIN_SIZEor greater thanMAX_SIZE.
-
getHeight
int getHeight()Get the value of theAttributes.HEIGHTattribute.If the attribute has no value, or is not a valid number,
DEFAULT_SIZEis returned.Note: There is a brief window of time when the value returned by this method differs from
getCanvas()'sCanvas.getHeight(). This happens when the attribute is changed, as canvas is updated after all attribute change listeners have been called.- Returns:
- Height
-
setHeight
Set the value ofAttributes.HEIGHTattribute.When called, the
getCanvas()'sCanvas.getHeight()will not be updated instantly. All attribute update listeners will be called first, then the canvas' size will be updated.When a canvas' size is changed, the canvas is resized, and any existing image data is retained, but the image will be cropped if the size is changed to smaller value than it was before.
- Parameters:
height- New height- Throws:
IllegalArgumentException- Ifheightis less thanMIN_SIZEor greater thanMAX_SIZE.
-
getCanvas
-