当前位置:网站首页>端午节快乐!—— canvas写的粽子~~~~~
端午节快乐!—— canvas写的粽子~~~~~
2022-07-03 09:06:00 【一麻袋小猫】

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>端午</title>
<script type="application/javascript">
function draw() {
var canvas = document.getElementById("canvas");
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
ctx.font = "48px serif";
ctx.textBaseline = "hanging";
ctx.strokeText("端午节吃粽子!", 0, 150);
//叶子
ctx.beginPath();
ctx.moveTo(20, 100);
ctx.quadraticCurveTo(150, 150, 300, 70);
ctx.quadraticCurveTo(150, 20, 20, 100);
ctx.fillStyle = "#07C160";
ctx.fill();
// 叶子纹理
ctx.beginPath();
ctx.moveTo(20, 100);
ctx.lineTo(300, 70);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(170, 85);
ctx.lineTo(150, 118);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(230, 76);
ctx.lineTo(200, 108);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(230, 76);
ctx.lineTo(200, 50);
ctx.stroke();
//第二个粽子
ctx.beginPath();
ctx.moveTo(150, 0);
ctx.quadraticCurveTo(25, 87, 125, 75);
ctx.quadraticCurveTo(75, 75, 225, 75);
ctx.quadraticCurveTo(170, 0, 150, 0);
ctx.fillStyle = "#EED3B5";
ctx.fill();
// // 第二个粽子阴影
ctx.beginPath();
ctx.moveTo(150, 10);
ctx.quadraticCurveTo(25, 87, 145, 55);
ctx.quadraticCurveTo(55, 65, 200, 55);
ctx.quadraticCurveTo(170, 10, 150, 10);
ctx.fillStyle = "#FBE8D1";
ctx.fill();
//第一个粽子
ctx.beginPath();
ctx.moveTo(85, 25);
ctx.quadraticCurveTo(25, 87, 30, 100);
ctx.quadraticCurveTo(90, 100, 150, 100);
ctx.quadraticCurveTo(120, 25, 85, 25);
ctx.fillStyle = "#EED3B5";
ctx.fill();
// 第一个粽子阴影
ctx.beginPath();
ctx.moveTo(85, 35);
ctx.quadraticCurveTo(25, 87, 55, 80);
ctx.quadraticCurveTo(80, 90, 130, 80);
ctx.quadraticCurveTo(120, 35, 85, 35);
ctx.fillStyle = "#FBE8D1";
ctx.fill();
// 粽子表情
ctx.beginPath();
ctx.moveTo(107, 55);
ctx.arc(102, 55, 5, 0, Math.PI, true); //眼 1
ctx.moveTo(92, 55);
ctx.arc(87, 55, 5, 0, Math.PI, true); //眼 1
ctx.moveTo(146, 25);
ctx.arc(139, 25, 5, 0, Math.PI, true); //眼 2
ctx.moveTo(161, 25);
ctx.arc(156, 25, 5, 0, Math.PI, true); //眼 2
ctx.moveTo(100, 65);
ctx.arc(95, 65, 5, 0, Math.PI, false); // 口(顺时针)
ctx.stroke();
// 第二个粽子
ctx.beginPath();
ctx.moveTo(160, 45);
ctx.arc(150, 45, 10, 0, Math.PI, false); // 口(顺时针)
ctx.fillStyle = "#000";
ctx.fill();
}
}
</script>
</head>
<body onload="draw();">
<canvas id="canvas" width="500" height="500"></canvas>
</body>
</html>
边栏推荐
- Arduino handles JSON data, arduinojson assistant
- Find all possible recipes from given supplies
- Epoll read / write mode in LT and et modes
- MySQL environment variable configuration
- ERROR: certificate common name “*.” doesn’t match requested ho
- Please tell me how to set vscode
- MySQL data manipulation language DML common commands
- 制作jetson nano最基本的根文件系统、服务器挂载NFS文件系统
- Trial of the combination of RDS and crawler
- Flink学习笔记(八)多流转换
猜你喜欢

Electronic product design

Modify idea code

Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 5 --blinker_ MIOT_ MULTI_ Outside (lighting technology app + Xiaoai classmate control socket multiple jacks)

Analysis of the implementation principle of an open source markdown to rich text editor

Difference of EOF

Nr-prach:prach format and time-frequency domain

Solve editor MD uploads pictures and cannot get the picture address

UCI and data multiplexing are transmitted on Pusch - Part I
![Successful graduation [2] - student health management system function development...](/img/91/72cdea3eb3f61315595330d2c9016d.png)
Successful graduation [2] - student health management system function development...
![【順利畢業】[1]-遊覽 [學生管理信息系統]](/img/91/72cdea3eb3f61315595330d2c9016d.png)
【順利畢業】[1]-遊覽 [學生管理信息系統]
随机推荐
MySQL environment variable configuration
Shell logic case
Convert IP address to int
专利查询网站
Flink学习笔记(十一)Table API 和 SQL
PRACH --- originator
Flink学习笔记(十)Flink容错机制
Long类型的相等判断
LeetCode每日一题(2090. K Radius Subarray Averages)
NR technology -- MIMO
Leetcode daily question (745. prefix and suffix search)
Flink learning notes (IX) status programming
Esp32 at command does not respond
Directory and switching operation in file system
Learn the contents of 5g toolbox supporting NR through the NR resources provided by MATLAB
[solution to the new version of Flink without bat startup file]
Flink学习笔记(九)状态编程
Electronic product design, MCU development, circuit cloning
PowerDesigner does not display table fields, only displays table names and references, which can be modified synchronously
制作jetson nano最基本的根文件系统、服务器挂载NFS文件系统