WebGL: Create-animate
learn WebGl Layer - Element creation and animation of its attributes.
Create an HTML container with ID to render the graphical context element
Layer Creation:
To create the WebGL layer, invoke the webglLayer method with ContainerID "#myWebgl". It returns webGL-2D renderer instance. For more details on webglLayer please refer : API Reference -> Layers -> WebGL Layer Page.
Element Creation:
To render elements, first, we need to create the shader group and then add elements to it. Without the shader group, elements won't be rendered. For example, to create a circle, we need to create a circle shader group and then rect elements.
Code block to create rects.
Let's create a circle element.
Animation:
Now we will animate circle radius from 50 to 200 and fillStyle from '#ff0000' to '#00ff00' in duration - 500 ms. By specifying loop = 10, animation will be repeated 10 time, with alternate direction and easeInOutSin easing.
Last updated