HTML5canvas绘制花朵

时间:2025-07-14

<!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字,全部文档内容请下载后查看。喜欢就下载吧 ……
HTML5canvas绘制花朵.doc 将本文的Word文档下载到电脑

    精彩图片

    热门精选

    大家正在看

    × 游客快捷下载通道(下载后可以自由复制和排版)

    限时特价:7 元/份 原价:20元

    支付方式:

    开通VIP包月会员 特价:29元/月

    注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
    微信:fanwen365 QQ:370150219