当前位置:网站首页>端午节快乐!—— 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>
边栏推荐
- Call the contents of Excel cells opened at the same time - button line feed
- MySQL Data Definition Language DDL common commands
- LeetCode每日一题(1856. Maximum Subarray Min-Product)
- Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 4 --blinker_ DHT_ WiFi (lighting technology app control + temperature and humidity data app display)
- Development of fire power monitoring system
- Jetson nano custom boot icon kernel logo CBOOT logo
- Flink learning notes (VIII) multi stream conversion
- 基于opencv实现桌面图标识别
- Learning C language from scratch -- installation and configuration of 01 MinGW
- [csdn] C1 analyse des questions de formation Partie III Bar _ JS Foundation
猜你喜欢

How does the nr-prach receiver detect the relationship between prembleid and Ta

Vscode Arduino installation Library

Directory and switching operation in file system

Please tell me how to set vscode

Apply for domain name binding IP to open port 80 record

Common software open source protocols

Hudi quick experience (including detailed operation steps and screenshots)

PolyWorks script development learning notes (II) -treeview basic operations

Nodemcu-esp8266 development board to build Arduino ide development environment

Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 3 --blinker_ MIOT_ Light (lighting technology app control + Xiaoai classmate control)
随机推荐
307. Range Sum Query - Mutable
Leetcode daily question (745. prefix and suffix search)
Vscode Arduino installation Library
Solve editor MD uploads pictures and cannot get the picture address
Powerdesign reverse wizard such as SQL and generates name and comment
Leetcode daily question (1856. maximum subarray min product)
小王叔叔的博客目录【持续更新中】
[CSDN]C1训练题解析_第二部分_Web基础
软件测试工程师是做什么的 通过技术测试软件程序中是否有漏洞
【男保姆式】教你打开第一个微信小程序
Make the most basic root file system of Jetson nano and mount NFS file system on the server
[solution to the new version of Flink without bat startup file]
Leetcode daily question (2109. adding spaces to a string)
1922. Count Good Numbers
Esp32 at command does not respond
UCI and data multiplexing are transmitted on Pusch - Part I
PRACH --- originator
Convert IP address to int
LeetCode每日一题(1856. Maximum Subarray Min-Product)
【顺利毕业】[1]-游览 [学生管理信息系统]