qq_小白菜_13
2016-11-12 16:40
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<canvas id="canvas" style="border:1px solid #aaa;display:block;margin:50px auto;">
当浏览器不支持Canvas,请更换浏览器后再试
</canvas>
<script>
window.onload=function(){
var canvas=document.getElementById("canvas");
canvas.width=1024;
canvas.height=768;
var context=canvas.getContext("2d");
context.beginPath();//声明一个新的绘制
context.moveTo(100,100);
context.lineTo(700,700);
context.lineTo(100,700);
context.lineTo(100,100);
context.closePath();//与beginPath()对应
context.lineWidth=5; //画出的线的宽度
context.strokeStyle="red";//设置画线的样式
context.stroke();//用于绘制线条
context.beginPath();
contetx.moveTo(200,100);
context.lineTo(700,600);
context.closePath();
context.strokeStyle="black";
context.stroke();
}
</script>
</body>
context.moveTo(200,100);
context写错了=。=
麻烦谁发个可以画出那黑色线条的代码给我看看咯
炫丽的倒计时效果Canvas绘图与动画基础
96746 学习 · 1000 问题
相似问题