html5中,canvas画不了图了,之前还是可以的,现在不知道除了什么问题,大大们帮忙看看,有重谢!!!!!
<!DOCTYPEHTML><html><head><metahttp-equiv="Content-Type"content="text/html;charset=ut...
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>拼图</title>
<style type="text/css">
body{background-color:#C9F;}
#difficulty_width{position:absolute; left:50px;top:50px;}
#difficulty_height{position:absolute; left:150px;top:50px;}
#register{background-color:#99F;outline-style: outset;}
#get_value{position:absolute; left:200px;top:350px;}
</style>
<script type="text/javascript">
var img=new Image;
img.src="aaa.jpg";
var POS={
X:0,
Y:0
};
var isMove=false;
</script>
</head>
<body>
<div id='main'></div>
<div id='realimg' ></div>
<canvas id="buttom" height=“100%” width=“100%”></canvas>
<div id="register" style="filter:Alpha(opacity=70); position:absolute; left:200px; top:100px; height:400px; width:600px;">
<select name="difficulty_width" id="difficulty_width" >
<option value="2" selected="selected">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="difficulty_height" id="difficulty_height" >
<option value="2" selected="selected">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<p><button type="submit" id="get_value" onClick="init()"><strong>确定</strong></button></p>
</div>
<script type="text/javascript">
var width_clip,height_clip;//宽和高上的格子个数
var piece_width,piece_height;//每个切片得宽和高
function init(){
width_clip=document.getElementById("difficulty_width").value;
height_clip=document.getElementById("difficulty_height").value;
var isMove=false;
var register=document.getElementById("register");
register.style.display="none";//把register的版块消掉
piece_width=img.width/width_clip;
piece_height=img.height/height_clip;
var c = document.getElementById("buttom");
var context = c.getContext("2d");
img.onload=function(){
for(var i=0;i<height_clip;i++){
for(var j=0;j<width_clip;j++){
if(i==0&&j==0)
continue;
else
context.drawImage(img,piece_width*j,piece_height*i,piece_width,piece_height,piece_width*j,piece_height*i,piece_width-1,piece_height-1);
}
}
}
img.src="aaa.jpg";
}
就是这块画不了,我都快哭出来了,弄了很长很长时间了 展开
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>拼图</title>
<style type="text/css">
body{background-color:#C9F;}
#difficulty_width{position:absolute; left:50px;top:50px;}
#difficulty_height{position:absolute; left:150px;top:50px;}
#register{background-color:#99F;outline-style: outset;}
#get_value{position:absolute; left:200px;top:350px;}
</style>
<script type="text/javascript">
var img=new Image;
img.src="aaa.jpg";
var POS={
X:0,
Y:0
};
var isMove=false;
</script>
</head>
<body>
<div id='main'></div>
<div id='realimg' ></div>
<canvas id="buttom" height=“100%” width=“100%”></canvas>
<div id="register" style="filter:Alpha(opacity=70); position:absolute; left:200px; top:100px; height:400px; width:600px;">
<select name="difficulty_width" id="difficulty_width" >
<option value="2" selected="selected">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="difficulty_height" id="difficulty_height" >
<option value="2" selected="selected">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<p><button type="submit" id="get_value" onClick="init()"><strong>确定</strong></button></p>
</div>
<script type="text/javascript">
var width_clip,height_clip;//宽和高上的格子个数
var piece_width,piece_height;//每个切片得宽和高
function init(){
width_clip=document.getElementById("difficulty_width").value;
height_clip=document.getElementById("difficulty_height").value;
var isMove=false;
var register=document.getElementById("register");
register.style.display="none";//把register的版块消掉
piece_width=img.width/width_clip;
piece_height=img.height/height_clip;
var c = document.getElementById("buttom");
var context = c.getContext("2d");
img.onload=function(){
for(var i=0;i<height_clip;i++){
for(var j=0;j<width_clip;j++){
if(i==0&&j==0)
continue;
else
context.drawImage(img,piece_width*j,piece_height*i,piece_width,piece_height,piece_width*j,piece_height*i,piece_width-1,piece_height-1);
}
}
}
img.src="aaa.jpg";
}
就是这块画不了,我都快哭出来了,弄了很长很长时间了 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询