Canvas画刮刮楽
1405 ワード
Document
var cvs = document.getElementById("out")
var con = document.getElementById("con")
var arr = [" ","100w"," "]
var i = Math.floor(Math.random()*arr.length)
con.innerHTML = arr[i]
var ctx = cvs.getContext("2d");
ctx.beginPath()
ctx.fillStyle="#ccc"
ctx.fillRect(0,0,cvs.width,cvs.height)
ctx.closePath()
cvs.onmousedown = function(){
document.onmousemove=function(e){
ctx.clearRect(e.clientX-cvs.offsetLeft,e.clientY-cvs.offsetTop,20,20)
}
document.onmouseup=function(){
document.onmousedown = null;
document.onmousemove=null;
}
}