<canvas width="600" height="400">
</canvas>
<script type="text/javascript">
function pintarRectangulos(numRectangulos, ancho, alto, color, colorBorde){
var canvas = document.querySelector("canvas");
var pincel = canvas.getContext("2d");
pincel.fillStyle = color;
pincel.strokeStyle = colorBorde;
var x = 0;
var y = 0;
for(var i = 0; i < numRectangulos; i++){
pincel.fillRect(x, y, ancho, alto);
pincel.strokeRect(x, y, ancho, alto);
x += ancho;
if(x == canvas.width){
x = 0;
y += alto;
}
}
}
pintarRectangulos(10, 100, 100, "pink", "darkblue");
</script>