HTML5 Canvas 绘制二次曲线【每日一段代码31】

<!DOCTYPE html>
<html>
<head>
<title>HTML5 Canvas 绘制二次曲线</title>
<script>
window.onload=function(){
var canvas=document.getElementById("myCanvas");
var context=canvas.getContext("2d");
context.lineWidth=10;
context.strokeStyle="red";
context.moveTo(100,canvas.height-50);
context.quadraticCurveTo(canvas.width/2,-50,canvas.width-100,canvas.height-50);
context.stroke();
}
</script>
</head>
<body style="margin:100px 50px;">
<canvas id="myCanvas" width="600" height="250" style="border:#06f solid 2px;"></canvas>
</body>
</html>

 

显示效果如下:

 

本实例来自网络。传送门:http://demo.cnmsdn.com/demo36.html

posted on 2012-02-29 22:13  Cosimo  阅读(314)  评论(0编辑  收藏  举报

导航