-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
37 lines (35 loc) · 1.14 KB
/
index.html
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
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<body onload="draw();">
<canvas id="canvas" width="900" height="600"></canvas>
</body>
<script type="text/javascript">
function draw() {
var ctx = document.getElementById("canvas").getContext("2d");
var cWidth = ctx.canvas.clientWidth;
console.log(cWidth);
var cHeight = ctx.canvas.clientHeight;
console.log(cHeight);
var codeImg =
"https://vannvan.github.io/web-explore-demo/images/code.png";
let qImg = new Image();
qImg.src = codeImg;
var backimg = new Image();
backimg.src =
"https://vannvan.github.io/web-explore-demo/images/img1.jpg";
backimg.onload = function () {
ctx.drawImage(backimg, 0, 0);
ctx.drawImage(qImg, cWidth - 220, cHeight - 220, 100, 100); // 在canvas 添加二维码
ctx.fillStyle = "#f00";
ctx.font = "48px serif";
ctx.fillText("Hello world", 30, 50);
// imgbox.src = ctx.toDataURL("image/jpeg", 1.0) // 输出图片
};
}
</script>
</body>
</html>