Html5中Canvas画布:我设置画布大小为:100*100,但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">
#nh {
height: 100px;
width: 100px;
border: 2px solid #F00;
}
</style>
<script>
window.onload=function ()
{
var c=document.getElementById('nh')
if(c.getContext)
{
}
else
{
alert('您的浏览器不支持本网页技术!请更新浏览器')
}
var od=c.getContext('2d')
od.moveTo(0,50)
od.lineTo(50,0)
od.lineTo(100,50)
od.lineTo(50,100)
od.lineTo(0,50)
od.stroke()
}
</script>
</head>
<body>
<canvas id='nh'></canvas>
</body>
</html> 展开
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style type="text/css">
#nh {
height: 100px;
width: 100px;
border: 2px solid #F00;
}
</style>
<script>
window.onload=function ()
{
var c=document.getElementById('nh')
if(c.getContext)
{
}
else
{
alert('您的浏览器不支持本网页技术!请更新浏览器')
}
var od=c.getContext('2d')
od.moveTo(0,50)
od.lineTo(50,0)
od.lineTo(100,50)
od.lineTo(50,100)
od.lineTo(0,50)
od.stroke()
}
</script>
</head>
<body>
<canvas id='nh'></canvas>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询