-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanvas1.html
52 lines (48 loc) · 927 Bytes
/
canvas1.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
canvas{
border: 1px solid #ccc;
}
</style>
</head>
<body>
<canvas id="can" width="500px" height="500px">该浏览器不支持</canvas>
</body>
<script type="text/javascript">
var can=document.getElementById("can");
var tx=can.getContext("2d");
tx.fillStyle="#ffff00";
// tx.beginPath();
//
// tx.moveTo(10,10);
//
// tx.lineTo(200,300);
// tx.lineTo(200,10);
// tx.lineTo(10,10);
// tx.fill();
// tx.beginPath();
// tx.moveTo(20,400);
// tx.lineTo(300,400);
// tx.lineTo(300,500);
// tx.lineTo(20,500);
// tx.lineTo(20,400);
// tx.fill();
tx.rect(10,10,200,300);
tx.fill()
tx.closePath();
tx.beginPath();
tx.rect(50,50,200,300);
tx.fillStyle="#00ff00";
tx.fill()
tx.closePath();
tx.beginPath();
tx.rect(100,100,200,300);
tx.fillStyle="#00ffff";
tx.fill()
tx.stroke();
</script>
</html>