<body> | |
<canvas id="canvas" width="200" height="200"></canvas> | |
<script> | |
const canvas = document.getElementById("canvas"); | |
const ctx = canvas.getContext("2d"); | |
const width = canvas.width; | |
const height = canvas.height; | |
ctx.fillStyle = "green"; | |
ctx.fillRect(0, 0, width / 2, height / 2); | |
</script> | |
</body> |