Canvas: Create-animate
learn Canvas Layer - Element creation and animation of its attributes.
Last updated
learn Canvas Layer - Element creation and animation of its attributes.
Last updated
Create an HTML container with ID to render the graphical context element
To create the Canvas layer, invoke canvasLayer method with ContainerID "#myCanvas", context config and Layer config objects as arguments. It returns the renderer instance. For more details on canvasLayer please refer: API Reference -> Layers -> Canvas Layer Page.
renderer.createEl() API creates Element of type 'el' with 'attr' attributes and 'style' properties. In the below example we are creating Circle with attributes specified in the attr object and styles in the style object.
To create multiple circles based on Data array - call createEls(DataArray, ElementConfig)
AnimateTo API is used for animating properties of the graphical elements. In the below code we are animating radius from 50 to 200 and fillStyle from '#ff0000' to '#00ff00' in duration - 500 ms. By specifying loop = 10, the animation will be repeated 10 times, with alternate direction and easeInOutSin easing.