Class HTMLCanvasElement

Class HTMLCanvasElement

Namespace: Aspose.Html
Assembly: Aspose.HTML.dll (25.4.0)

The HTMLCanvasElement interface provides properties and methods for manipulating the layout and presentation of canvas elements. The HTMLCanvasElement interface also inherits the properties and methods of the HTMLElement interface.

[ComVisible(true)]
[DOMName("HTMLCanvasElement")]
[DOMObject]
public class HTMLCanvasElement : HTMLElement, INotifyPropertyChanged, IEventTarget, IDisposable, IXPathNSResolver, IParentNode, IElementTraversal, IChildNode, IElementCSSInlineStyle, IGlobalEventHandlers

Inheritance

objectDOMObjectEventTargetNodeElementHTMLElementHTMLCanvasElement

Implements

INotifyPropertyChanged, IEventTarget, IDisposable, IXPathNSResolver, IParentNode, IElementTraversal, IChildNode, IElementCSSInlineStyle, IGlobalEventHandlers

Inherited Members

HTMLElement.Id, HTMLElement.Title, HTMLElement.Lang, HTMLElement.Dir, HTMLElement.ClassName, HTMLElement.Style, HTMLElement.OnAbort, HTMLElement.OnBlur, HTMLElement.OnCancel, HTMLElement.OnCanplay, HTMLElement.OnCanPlayThrough, HTMLElement.OnChange, HTMLElement.OnClick, HTMLElement.OnCueChange, HTMLElement.OnDblClick, HTMLElement.OnDurationChange, HTMLElement.OnEmptied, HTMLElement.OnEnded, HTMLElement.OnError, HTMLElement.OnFocus, HTMLElement.OnInput, HTMLElement.OnInvalid, HTMLElement.OnKeyDown, HTMLElement.OnKeyPress, HTMLElement.OnKeyUp, HTMLElement.OnLoad, HTMLElement.OnLoadedData, HTMLElement.OnLoadedMetadata, HTMLElement.OnLoadStart, HTMLElement.OnMouseDown, HTMLElement.OnMouseEnter, HTMLElement.OnMouseLeave, HTMLElement.OnMouseMove, HTMLElement.OnMouseOut, HTMLElement.OnMouseOver, HTMLElement.OnMouseUp, HTMLElement.OnMouseWheel, HTMLElement.OnPause, HTMLElement.OnPlay, HTMLElement.OnPlaying, HTMLElement.OnProgress, HTMLElement.OnRateChange, HTMLElement.OnReset, HTMLElement.OnResize, HTMLElement.OnScroll, HTMLElement.OnSeeked, HTMLElement.OnSeeking, HTMLElement.OnSelect, HTMLElement.OnShow, HTMLElement.OnStalled, HTMLElement.OnSubmit, HTMLElement.OnSuspend, HTMLElement.OnTimeUpdate, HTMLElement.OnToggle, HTMLElement.OnVolumeChange, HTMLElement.OnWaiting, Element.GetAttributeNames(), Element.HasAttributes(), Element.GetAttribute(string), Element.GetAttributeNS(string, string), Element.SetAttribute(string, string), Element.SetAttributeNS(string, string, string), Element.RemoveAttribute(string), Element.RemoveAttributeNS(string, string), Element.HasAttribute(string), Element.HasAttributeNS(string, string), Element.ToggleAttribute(string), Element.ToggleAttribute(string, bool), Element.GetAttributeNode(string), Element.SetAttributeNode(Attr), Element.RemoveAttributeNode(Attr), Element.GetAttributeNodeNS(string, string), Element.SetAttributeNodeNS(Attr), Element.GetElementsByTagName(string), Element.GetElementsByTagNameNS(string, string), Element.Remove(), Element.QuerySelectorAll(string), Element.QuerySelector(string), Element.AttachShadow(ShadowRootMode), Element.GetElementsByClassName(string), Element.Dispose(bool), Element.ClassList, Element.LocalName, Element.NamespaceURI, Element.Prefix, Element.NodeName, Element.NodeType, Element.TagName, Element.Id, Element.ClassName, Element.TextContent, Element.Attributes, Element.FirstElementChild, Element.LastElementChild, Element.PreviousElementSibling, Element.NextElementSibling, Element.ChildElementCount, Element.Children, Element.InnerHTML, Element.OuterHTML, Element.ShadowRoot, Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE, Node.ENTITY_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.DOCUMENT_NODE, Node.DOCUMENT_TYPE_NODE, Node.DOCUMENT_FRAGMENT_NODE, Node.NOTATION_NODE, Node.HasChildNodes(), Node.Normalize(), Node.CloneNode(), Node.CloneNode(bool), Node.IsEqualNode(Node), Node.IsSameNode(Node), Node.LookupPrefix(string), Node.LookupNamespaceURI(string), Node.IsDefaultNamespace(string), Node.InsertBefore(Node, Node), Node.ReplaceChild(Node, Node), Node.RemoveChild(Node), Node.AppendChild(Node), Node.Dispose(bool), Node.ToString(), Node.NodeType, Node.LocalName, Node.NamespaceURI, Node.Prefix, Node.NodeName, Node.BaseURI, Node.OwnerDocument, Node.ParentNode, Node.ParentElement, Node.ChildNodes, Node.FirstChild, Node.LastChild, Node.PreviousSibling, Node.NextSibling, Node.NodeValue, Node.TextContent, EventTarget.AddEventListener(string, DOMEventHandler, bool), EventTarget.AddEventListener(string, IEventListener), EventTarget.AddEventListener(string, IEventListener, bool), EventTarget.RemoveEventListener(string, DOMEventHandler, bool), EventTarget.RemoveEventListener(string, IEventListener), EventTarget.RemoveEventListener(string, IEventListener, bool), EventTarget.DispatchEvent(Event), EventTarget.Dispose(), EventTarget.Dispose(bool), DOMObject.GetPlatformType(), object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Properties

Height

Is 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.

[DOMName("height")]
public ulong Height { get; set; }

Property Value

ulong

Width

Is 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.

[DOMName("width")]
public ulong Width { get; set; }

Property Value

ulong

Methods

GetContext(string)

Returns a drawing context on the canvas, or null if the context ID is not supported. A drawing context lets you draw on the canvas.

[DOMName("getContext")]
public object GetContext(string contextId)

Parameters

contextId string

Is a string containing the context identifier defining the drawing context associated to the canvas

Returns

object

A RenderingContext

ToDataURL()

returns a data URI containing a representation of the image in the format specified by the type parameter (defaults to PNG). The returned image is in a resolution of 96 dpi.

[DOMName("toDataURL")]
public string ToDataURL()

Returns

string

A DOMString containing the requested data URI.

ToDataURL(string)

returns a data URI containing a representation of the image in the format specified by the type parameter (defaults to PNG). The returned image is in a resolution of 96 dpi.

[DOMName("toDataURL")]
public string ToDataURL(string type)

Parameters

type string

A string indicating the image format. The default format type is image/png.

Returns

string

A DOMString containing the requested data URI.

ToDataURL(string, double)

returns a data URI containing a representation of the image in the format specified by the type parameter (defaults to PNG). The returned image is in a resolution of 96 dpi.

[DOMName("toDataURL")]
public string ToDataURL(string type, double encoderOptions)

Parameters

type string

A string indicating the image format. The default format type is image/png.

encoderOptions double

A Number between 0 and 1 indicating image quality if the requested type is image/jpeg or image/webp.

Returns

string

A DOMString containing the requested data URI.