当前位置:网站首页>端午节快乐!—— 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>
边栏推荐
- The idea of compiling VBA Encyclopedia
- Installation and uninstallation of pyenv
- 1922. Count Good Numbers
- Shell logic case
- 2021-09-26
- Call the contents of Excel cells opened at the same time - button line feed
- 解决Editor.md上传图片获取不到图片地址问题
- PowerDesigner does not display table fields, only displays table names and references, which can be modified synchronously
- Successful graduation [2] - student health management system function development...
- PolyWorks script development learning notes (4) - data import and alignment using file import
猜你喜欢

CATIA automation object architecture - detailed explanation of application objects (III) systemservice
![[CSDN]C1训练题解析_第二部分_Web基础](/img/91/72cdea3eb3f61315595330d2c9016d.png)
[CSDN]C1训练题解析_第二部分_Web基础

Leetcode daily question (931. minimum falling path sum)

Nr-prach:prach format and time-frequency domain

Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 4 --blinker_ DHT_ WiFi (lighting technology app control + temperature and humidity data app display)

Trial of the combination of RDS and crawler

软件测试工程师是做什么的 通过技术测试软件程序中是否有漏洞

解决Editor.md上传图片获取不到图片地址问题

Nodemcu-esp8266 development board to build Arduino ide development environment

Definition and use of enum in C language
随机推荐
Intelligent home design and development
Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 3 --blinker_ MIOT_ Light (lighting technology app control + Xiaoai classmate control)
LeetCode每日一题(2109. Adding Spaces to a String)
307. Range Sum Query - Mutable
Jestson Nano 从tftp服务器下载更新kernel和dtb
从0开始使用pnpm构建一个Monorepo方式管理的demo
【男保姆式】教你打开第一个微信小程序
Long类型的相等判断
Call the contents of Excel cells opened at the same time - button line feed
Win10安装ELK
Leetcode daily question (985. sum of even numbers after queries)
[combinatorics] Introduction to Combinatorics (combinatorial thought 2: mathematical induction | mathematical induction promotion | multiple induction thought)
Arduino handles JSON data, arduinojson assistant
Difference of EOF
Apply for domain name binding IP to open port 80 record
PowerDesigner does not display table fields, only displays table names and references, which can be modified synchronously
Directory and switching operation in file system
Electronic product design, MCU development, circuit cloning
Jetson Nano 自定义启动图标kernel Logo cboot logo
Quickly use markdown to edit articles