Artículo Introducción de Wulin.com (www.vevb.com): rectángulos HTML5-Canvas Tag-Drawing.
<! Doctype html>
<html>
<Evista>
<meta charset = 'utf-8'>
<title> html5-canvas etiqueta-draw rectangle </title>
</ablo>
<Body>
<Canvas id = 1 ancho = 200 alturas = 200> </Canvas>
<script type = text/javaScript>
window.onload = function () {
var canva = document.getElementById ('1')
VAR Content = Canva.getContext ('2d')
content.fillstyle = #ccc; // llena el color de fondo del lienzo
content.fillrect (0, 0, 200, 200); // Los parámetros representan el eje x, el eje y, el ancho y la altura respectivamente
content.linewidth = 4; // ancho del borde
content.StrokeStyle = #fff; // border color
content.Strokerect (50,50,100,100); // Coordenadas y tamaños de la frontera
content.fillstyle = #f00; // color de relleno rectángulo
content.fillrect (50,50,100,100); // coordenadas y tamaño de rectángulo
}
</script>
</body>
</html>