当前位置:网站首页>端午节快乐!—— 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>
边栏推荐
- PowerDesigner does not display table fields, only displays table names and references, which can be modified synchronously
- Shell logic case
- LeetCode每日一题(2115. Find All Possible Recipes from Given Supplies)
- PolyWorks script development learning notes (4) - data import and alignment using file import
- 顺利毕业[3]-博客系统 更新中。。。
- LeetCode每日一题(1162. As Far from Land as Possible)
- Leetcode daily question (1162. as far from land as possible)
- Flink learning notes (10) Flink fault tolerance mechanism
- Spark overview
- Integrated use of interlij idea and sonarqube
猜你喜欢
Intelligent home design and development
Analysis of the implementation principle of an open source markdown to rich text editor
LeetCode每日一题(2212. Maximum Points in an Archery Competition)
全球KYC服务商ADVANCE.AI 活体检测产品通过ISO国际安全认证 产品能力再上一新台阶
[successful graduation] [1] - visit [student management information system]
LeetCode每日一题(1162. As Far from Land as Possible)
Flink learning notes (XI) table API and SQL
Development of fire power monitoring system
Vscode Arduino installation Library
Nr-prach: access scenario and access process
随机推荐
基于opencv实现桌面图标识别
1300. sum of varied array closed to target
Win10 install elk
Intelligent home design and development
Starting from 0, use pnpm to build a demo managed by monorepo
Leetcode daily question (1856. maximum subarray min product)
Spark overview
Quickly use markdown to edit articles
Shell logic case
Leetcode daily question (931. minimum falling path sum)
LeetCode每日一题(2115. Find All Possible Recipes from Given Supplies)
LeetCode每日一题(1996. The Number of Weak Characters in the Game)
UCI and data multiplexing are transmitted on Pusch (Part 4) --small block lengths
[CSDN]C1训练题解析_第三部分_JS基础
The rise and fall of mobile phones in my perspective these 10 years
Apply for domain name binding IP to open port 80 record
Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 1 -- establishment of engineering template -template
Development of fire power monitoring system
Jestson Nano 从tftp服务器下载更新kernel和dtb
LeetCode每日一题(2212. Maximum Points in an Archery Competition)