Constructor for the Ctx2D class.
Optional
initialProps: StaticProps & ChangeablePropsChecks if the canvas is ready to be rendered
Returns the current canvas element
Returns the height of the canvas without the device pixel ratio (DPR)
Returns the width of the canvas without the device pixel ratio (DPR)
The parent element of the canvas used to calculate size
Returns the 2D rendering context
Returns the current device pixel ratio (DPR)
Returns the current height of the canvas (with DPR applied)
Checks if the module has been destroyed.
Checks if the module has been initialized.
The name of the module, derived from the class name
Optional prefix for class names used by the module
The current properties of the module, which include both static and changeable properties. These can be retrieved dynamically during the module's lifecycle.
Returns the current width of the canvas (with DPR applied)
Adds a custom callback to the module.
Adds a DOM event listener that will be automatically removed when the module is destroyed.
The target element for the event listener.
The event type to listen for (e.g., 'click', 'resize').
The callback function to execute when the event is triggered.
Optional
options: boolean | AddEventListenerOptionsAdditional options for the event listener.
Adds a plugin to the component. The plugin is initialized upon being added,
and the plugin's component
property is set to the current component instance.
An instance of the Plugin class to be added.
Adds responsive property rules to the module. This must be done before initialization.
The responsive property rules to be added.
Adds a viewport callback that will be automatically removed when the module is destroyed.
The viewport target (e.g., width or height).
The callback function to execute when the viewport target changes.
Additional data for the callback.
Renders content on the canvas if it is ready.
A function that performs the actual rendering on the canvas.
A class that simplifies working with an HTML5 Canvas element and its 2D context. It can handle automatic resizing and provides helper methods for rendering and managing canvas properties.
Link
See examples https://antonbobrov.github.io/vevet-demo/ctx2d/
Link
See docs https://antonbobrov.github.io/vevet/classes/Ctx2D.html