-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrectStyle.html
More file actions
48 lines (37 loc) · 911 Bytes
/
rectStyle.html
File metadata and controls
48 lines (37 loc) · 911 Bytes
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
#cvs{border: 1px solid red;}
</style>
</head>
<body>
<canvas id="cvs" width="500" height="500"></canvas>
<script>
var cvs=document.getElementById("cvs");
if(cvs.getContext){
var ctx=cvs.getContext('2d');
//填充颜色:
//左侧
ctx.fillStyle="red";
ctx.fillRect(100,100,50,50);
ctx.fillStyle="blue";
ctx.fillRect(150,150,50,50);
ctx.fillStyle="red";
ctx.fillRect(200,200,50,50);
ctx.fillStyle="blue";
ctx.fillRect(250,250,50,50);
//右侧
ctx.fillStyle="red";
ctx.fillRect(300,200,50,50);
ctx.fillStyle="blue";
ctx.fillRect(350,150,50,50);
ctx.fillStyle="red";
ctx.fillRect(400,100,50,50);
}else{
}
</script>
</body>
</html>