<canvas width="600" height="400"></canvas>
<script>
var pantalla = document.querySelector("canvas");
var pincel = pantalla.getContext("2d");
pincel.fillStyle = "lightgray";
pincel.fillRect(0, 0, 600, 400);
function dibujarCirculo(x, y, radio, color) {
pincel.fillStyle = color;
pincel.beginPath();
pincel.arc(x, y, radio, 0, 2*3.14);
pincel.fill();
}
dibujarCirculo(300,200,20,"red");
dibujarCirculo(260,200,20,"red");
dibujarCirculo(340,200,20,"red");
var cantidad_circulo = 0
var color1 = "orange"
var color2 = "red"
var color3 = "black"
for(var x = 260; x <= 340; x = x + 40){
if(x == 260){
dibujarCirculo(x,200,20,"orange")}
if(x == 260+40){
dibujarCirculo(x,200,20,"red")}
if (x ==260+40+40){
dibujarCirculo(x,200,20,"black")}
}
for(var y = 160; y <= 240; y = y + 80){
if(y==160){
dibujarCirculo(300,y,20,"blue")}
if(y==240){
dibujarCirculo(300,y,20,"yellow")}
}
</script>