blob: 5cd7b829e5880fd767a45a09d1707d54955f915c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<!DOCTYPE html>
<head><meta charset="utf-8"></head>
<body>
<canvas id="canvas" width="100" height="100" style="background-color: #555555;"></canvas>
<script>
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");
const canvasTemp = document.createElement('canvas');
canvasTemp.width = 50;
canvasTemp.height = 50;
let ctxTemp = canvasTemp.getContext("2d");
ctxTemp.fillStyle = "#ff0000";
ctxTemp.fillRect(0, 0, 50, 50);
ctxTemp.fillStyle = "#00ff00";
ctxTemp.fillRect(2, 2, 46, 46);
ctx.drawImage(canvasTemp, 0, 0, 100, 100, 0, 0, 100, 100);
</script>
</body>
|