<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Canvas JS</title>
</head>
<body>
<canvas width="800" height="600"> </canvas>
<script>
function drawSquare(x, y, color, lineWidth, borderColor) {
var screen = document.querySelector("canvas");
var brush = screen.getContext("2d");
// grosor de línea borde
brush.lineWidth = lineWidth;
// color y tamaño de borde y relleno
brush.fillStyle = color;
brush.fillRect(x, y, 20, 20);
brush.strokeStyle = borderColor;
brush.strokeRect(x, y, 20, 20);
}
drawSquare(20, 20, "aqua", 2, "purple");
drawSquare(40, 20, "purple", 2, "aqua");
drawSquare(60, 20, "aqua", 2, "purple");
drawSquare(80, 20, "purple", 2, "aqua");
drawSquare(100, 20, "aqua", 2, "purple");
</script>
</body>
</html>