blob: 1d078129f323b44b20908a1184e3b84702118d22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<!DOCTYPE html>
<html>
<head>
<title>canvas drawImage() test</title>
<style>
canvas {
border: 1px solid black;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function() {
img = document.querySelector("img");
img.addEventListener("load", function() {
var ctx = document.querySelector("canvas").getContext("2d");
ctx.fillStyle = '#666';
ctx.fillRect(0, 0, 400, 400);
ctx.scale(2, 2);
ctx.drawImage(img, 30, 30);
});
});
</script>
</head>
<body>
<canvas width=400 height=400></canvas>
<img src="../../../res/graphics/buggie.png">
</body>
</html>
|