Missão dada! Missão cumprida! Segue minha solução:
<!DOCTYPE html>
<html lang="pt_BR">
<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">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
div {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 3px double brown;
padding: 25px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
}
div h1 {
margin-bottom: 5px;
color: brown;
}
canvas {
scale: (0.1);
animation: .8s ease-in-out 0s 1 normal both running aparecimento
}
@keyframes aparecimento {
from {
transform: scale(0.1);
}
to {
transform: scale(1.0);
}
}
</style>
<title>Esquadro Plus</title>
</head>
<body>
<div>
<h1>Esquadro #2</h1>
<canvas width="450" height="450"></canvas>
</div>
<script>
function getContext() {
return document.querySelector("canvas").getContext("2d");
}
function drawSetSquare(xa, ya, xc, yc, color) {
let context = getContext();
context.fillStyle = color;
context.beginPath();
context.moveTo(xa, ya);
context.lineTo(xa, yc);
context.lineTo(xc, yc);
context.fill();
context.fillStyle = "white";
context.beginPath();
context.moveTo(xa + 50, ya + 125);
context.lineTo(xa + 50, yc - 50);
context.lineTo(xc - 125, yc - 50);
context.fill();
}
drawSetSquare(50, 50, 400, 400, "blue");
</script>
</body>
</html>