<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>MyFlower</title>
<style type="text/css">
canvas{
width:800px;
height:800px;
border:1px solid red;
}
</style>
<script type="text/javascript">
function Draw()
{
var canvas=document.getElementById("canvas"); var context=canvas.getContext("2d");
context.translate(200,0);
//context.scale(0.5,0.5);
var i;
/*for(i=1;i<=24;i++)
{
context.rotate(Math.PI/6);
drawflower(context);
}*/
drawflower1(context);
drawflower2(context);
drawflower3(context);
drawflower4(context);
drawflower5(context);
drawline(context);
}
function drawflower1(context)
{
context.beginPath();
context.moveTo(200,400);
context.bezierCurveTo(250,380,300,350,400,420);
context.strokeStyle="pink"; // ñ context.lineWidth=3;
context.fillStyle="pink";
context.fill();
context.stroke();
context.beginPath();
context.moveTo(200,400);
context.bezierCurveTo(250,420,300,450,400,420);
context.strokeStyle="pink";
context.linewidth=3;
context.fillStyle="pink";
context.fill();
context.stroke();
}
function drawflower2(context)
{
context.beginPath();
context.moveTo(200,400);
context.bezierCurveTo(200,400,320,400,320,280);
context.strokeStyle="pink"; // ñ context.lineWidth=3;
context.fillStyle="pink";
context.fill();
context.stroke();
context.beginPath();
context.moveTo(200,400);
context.bezierCurveTo(200,340,260,300,320,280);
context.strokeStyle="pink";
context.linewidth=3;
context.fillStyle="pink";
context.fill();
context.stroke();
}
function drawflower3(context)
{
context.beginPath();
context.moveTo(200,400);
context.bezierCurveTo(280,400,300,450,290,520);
context.strokeStyle="pink"; // ñ context.lineWidth=3;
context.fillStyle="pink";
context.fill();
context.stroke();
context.beginPath();
context.moveTo(200,400);
context.bezierCurveTo(200,450,200,480,290,520);
context.strokeStyle="pink";
context.linewidth=3;
context.fillStyle="pink";
context.fill();
context.stroke();
}
function drawflower4(context)
{
context.beginPath();
context.moveTo(200,400);
context.bezierCurveTo(250,380,220,320,120,280);
context.strokeStyle="pink"; // ñ context.lineWidth=3;
context.fillStyle="pink";
context.fill();
context.stroke();
context.beginPath();
context.moveTo(200,400);
context.bezierCurveTo(100,380,140,340,120,280);
context.strokeStyle="pink";
context.linewidth=3;
context.fillStyle="pink";
context.fill();
context.stroke();
}
function drawflower5(context)
{
context.beginPath();
context.moveTo(200,400);
context.bezierCurveTo(250,420,200,480,80,480);
context.strokeStyle="pink"; // ñ context.lineWidth=3;
context.fillStyle="pink";
context.fill();
context.stroke();
context.beginPath();
context.moveTo(200,400);
context.bezierCurveTo(150,400,100,400,80,480);
context.strokeStyle="pink";
context.linewidth=3;
context.fillStyle="pink";
context.fill();
context.stroke();
}
function drawline(context)
{
context.beginPath();
context.moveTo(200,450);
context.bezierCurveTo(160,470,130,550,220,650); context.strokeStyle="green";
context.lineWidth=3;
context.stroke();
}
window.addEventListener("load", Draw,true); </script>
</head>
<body>
<canvas id="canvas" width="1000" height="800">
</canvas> </body> </html>
…… 此处隐藏:1023字,全部文档内容请下载后查看。喜欢就下载吧 ……