<!-- bandeiras.html -->
<!DOCTYPE html>
<html lang="en">
<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>Document</title>
</head>
<body>
<canvas width="600" height="400"></canvas>
<script>
var countryFlag = 1;
function desenhaBandeiraBrasil() {
var tela = document.querySelector("canvas");
var pincel = tela.getContext("2d");
pincel.fillStyle = "green";
pincel.fillRect(0, 0, 600, 400);
pincel.fillStyle = "yellow";
pincel.beginPath();
pincel.moveTo(300, 50);
pincel.lineTo(50, 200);
pincel.lineTo(550, 200);
pincel.fill();
pincel.beginPath();
pincel.moveTo(50, 200);
pincel.lineTo(300, 350);
pincel.lineTo(550, 200);
pincel.fill();
pincel.fillStyle = "darkblue";
pincel.beginPath();
pincel.arc(300, 200, 100, 0, 2 * 3.14);
pincel.fill();
}
function desenhaBandeiraAlemanha() {
var tela = document.querySelector("canvas");
var pincel = tela.getContext("2d");
pincel.fillStyle = "black";
pincel.fillRect(0, 0, 600, 133);
pincel.fillStyle = "red";
pincel.fillRect(0, 133, 600, 133);
pincel.fillStyle = "yellow";
pincel.fillRect(0, 266, 600, 133);
}
function changeFlag() {
if (countryFlag == 1) {
desenhaBandeiraBrasil();
countryFlag = 0;
} else if (countryFlag == 0) {
desenhaBandeiraAlemanha();
countryFlag = 1;
}
}
setInterval(changeFlag, 3000);
</script>
</body>
</html>