What is the use of Canvas in HTML ?

  • In HTML the <canvas> tag is used to draw graphics on a web page using JavaScript.
  • It can be used to draw boxes, gradients, texts, paths and adding images.
  • By default, it does not contain texts and borders.
  • It allows for scriptable and dynamic rendering of 2D shapes and bitmap images.
  • It does not have a built-in scene and becomes a low level, procedural model that updates a bitmap.
  • There are several methods using <canvas> tag.

For example,

[pastacode lang=”markup” manual=”%3C!DOCTYPE%20html%3E%0A%3Chtml%3E%0A%3Cbody%3E%0A%0A%3Ccanvas%20id%3D%22myCanvas%22%20width%3D%22400%22%20height%3D%22250%22%20style%3D%22border%3A1px%20solid%20%23d3d3d3%3B%22%3E%0AYour%20browser%20does%20not%20support%20the%20HTML%20canvas%20tag.%3C%2Fcanvas%3E%0A%0A%3Cscript%3E%0Avar%20c%20%3D%20document.getElementById(%22myCanvas%22)%3B%0Avar%20ctx%20%3D%20c.getContext(%222d%22)%3B%0Actx.font%20%3D%20%2230px%20Arial%22%3B%0Actx.fillText(%22Welcome%20to%20Wikitechy%22%2C10%2C50)%3B%0A%3C%2Fscript%3E%0A%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A” message=”” highlight=”” provider=”manual”/]

Output

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

What is the difference between SOAP and REST ?

                  SOAP                    REST It is a protocol. It is an architectural style. SOAP- Simple Object Access Protocol. REST- Representational State Transfer. It can’t use REST because it is a…
View Answer

What is Grid system ?

It is a structure comprising a series of vertical and horizontal lines which intersect and used to arrange content. Is a way of providing a system that designers can work with…
View Answer

What is Semantic HTML ?

It is essential to understand the meaning of words during communication in any language. It becomes more critical and provides more semantic elements which make it easy to understand the…
View Answer

What is Flexbox ?

It is a one-dimensional layout model that has efficient and flexible layouts with distributed spaces among items to control their alignment structure in CSS . It is a layout model…
View Answer