forked from Crise420WMT/crise420wmt.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawBoard.html
45 lines (43 loc) · 1.26 KB
/
drawBoard.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{margin: 0;padding: 0;}
.can{border: 1px solid red;background: silver;float:left;cursor:pointer;}
input{float: left;}
</style>
<script>
window.onload=function(){
var oCan=document.querySelector('.can');
var oBtn=document.querySelector('input');
var gd=oCan.getContext('2d');
oCan.onmousedown=function(ev){
var downX=ev.clientX;
var downY=ev.clientY;
gd.beginPath();
gd.moveTo(downX,downY);
oCan.onmousemove=function(ev){
gd.lineTo(ev.clientX,ev.clientY);
gd.stroke();
};
oCan.onmouseup=function(ev){
oCan.onmousemove=null;
oCan.onmouseup=null;
};
return false;
};
oBtn.onchange=function(){
gd.strokeStyle=this.value;
};
};
</script>
</head>
<body>
<canvas class="can" width="600" height="600">
抱歉,您的浏览器不支持canvas
</canvas>
<input type="color" name="" id=""/>
</body>
</html>