element is not supported in some older browsers, but is supported in recent versions of all major browsers. Learn how to scale the canvas and perform drawing operations. Each canvas may have an id using which you may target a specific canvas through JavaScript. Let's try it out to understand how it basically works: Similarly, you can fill canvas shapes with radial gradient using the createRadialGradient() method. The basic syntax for creating a linear gradient can be given with: The following example uses the createLinearGradient() method to fill a linear gradient color inside a rectangle. Copyright © 2021 Tutorial Republic. You can though bring responsiveness to Canvas Based graphics using some tweaks in JavaScript. A bit of explanation of what is needed to be done to create a simple animation with Canvas is as follows. As you can see in the code above, in order to draw a shape with shadow, you need to first specify the shadow properties before "drawing" the shape. Home CSS PHP-MySQL JavaScript Ajax Blog Forum. Here are samples and downloadable package: Live Demo [sociallocker] Here is a code example: Here is the result of the above code when drawn on a canvas: What is an HTML5 canvas? Officially a canvas is "a resolution-dependent bitmap canvas which can be used for rendering graphs, game graphics, or other visual images on the fly". Radius of the circle is 10 and its origin is at (x,y). The following section will explain you how to draw basic vector-based paths and shapes on the web pages using the newly introduced HTML5