blob: 553a75268655382bb69436a00573afadab331e35 [file] [log] [blame]
<style>
canvas {
width: 100px;
height: 100px;
}
</style>
<body>
<canvas id="canvas1"></canvas>
<canvas id="canvas2"></canvas>
<script>
function drawRect(id) {
const canvas = document.getElementById(id);
canvas.width = canvas.clientWidth;
canvas.height = canvas.clientHeight;
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(0, 0, 100, 100);
}
drawRect('canvas1');
drawRect('canvas2');
</script>
</body>