HTML5 - Canvas




HTML5 Canvas

In this section we are going to learn the Canvas in HTML5.

Canvas element is a rectangular area that can be used to draw lines, shapes, images, animations. Canvas doesn’t have its own drawing abilities; it is done through JavaScript programmatically.

It’s a smart choice to illustrate your website with pictures and photographs. However, there is a possibility to be creative and to draw with HTML. For that, you came to the right place – the HTML5 canvas tutorial.

In this HTML5 canvas tutorial, you’ll learn all you need to know about HTML5 CSS canvas, and what can you do with these drawing tools. This HTML5 canvas tutorial is based on HTML5 canvas tutorial with, but you will find HTML5 canvas examples too.

Although drawing by hand is sometimes a difficult task for some people, drawing with CSS canvas is also not that easy. It requires a good understanding of space and graphs. However, when you get used to it, it’s relatively fun and professional to include some graphics content on your website. Along with pictures and buttons, it creates the image of a good-quality website and a professional developer behind it.

Main Tips HTML5 Canvas

  • The HTML <canvas> element is used to produce graphics content on a website;

  • The <canvas> element has methods for drawing squares, circles, paths, text, and adding images;

  • The event handler is unsupported in <canvas>;

  • <canvas> is great for graphics-intensive games;

  • <canvas> is rendered pixel by pixel so, the entire scene needs to be reproduced in every frame.

  • <canvas> renders text poorly;

  • <canvas> depends on the resolution;

  • raws 2D graphics;

Example

<!DOCTYPE html>
<html>
<body>
<canvas id="ThisIsCanvas" width="300" height="300" style="border: 2px solid #000000;">
 HTML5 canvas tag is unsupported in your browser.
</canvas>

Result

HTML5 canvas tag is unsupported in your browser.