情人节送给粉丝的礼物
时间:2022-07-25
本文章向大家介绍情人节送给粉丝的礼物,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
怦然心动
今天是七夕,一个牛郎和织女鹊桥相会的日子。 还有他们的孩子也跟他们在一起。
感谢你们一直陪伴至今,我不善于表达,我对你们的感激都在这张画布里。
代码不算多,特效也不是很花哨,情人节她更在意的是你口中的甜言蜜语,这个动画是你们交流的开端。 祝愿你们心心念念的人也在念着你们,愿你们web学习一帆风顺,无往不利。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>砰砰砰</title>
<style>
body {
background: #000800;
}
canvas {
margin: 0 auto;
display: block;
}
</style>
</head>
<body>
<canvas></canvas>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';color:#ffffff">
</body>
<script>
let canvas = document.querySelector('canvas'),
speedSelect = document.querySelector('#speed'),
width = 300,
height = 300,
ctx = canvas.getContext('2d'),
pSystemSize = 1000,
deform = {a:100, s:0.4, min:-200, max:200, dir:1}; // a=4 is natural if not animated;
const mcos = Math.cos,
msin = Math.sin,
mpow = Math.pow,
PI180=Math.PI / 180,
tau = Math.PI * 2;
canvas.width = width;
canvas.height = height;
ctx.lineWidth = 1;
const ParticleSystem = function(num){
this.scalar = 8;
this.numParticles = num;
this.allParticles = [];
this.x = width * .5;
this.y = height * .5;
this.generate();
}
ParticleSystem.prototype.generate = function(){
for(let i=0; i<this.numParticles; i++){
let vo = {};
vo.degrees = (360 / this.numParticles) * i * PI180;
vo.parent = this;
vo.x = width / 2;
vo.y = height / 2;
vo.vx = 0;
vo.vy = 0;
this.allParticles.push(new Particle(vo));
}
}
ParticleSystem.prototype.update = function(){
for(let i=0; i<this.allParticles.length; i++){
this.allParticles[i].update();
}
}
const Particle = function(vo){
this.degrees = vo.degrees;
this.parent = vo.parent;
this.x = vo.x;
this.y = vo.y;
this.vx = 0;
this.vy = 0;
this.colour = 'hsl(' + (Math.round((this.degrees * (180/Math.PI)))) + ',100%,50%)';
}
Particle.prototype.update = function(){
// http://mathworld.wolfram.com/HeartCurve.html
this.vx = 16 * mpow(msin(this.degrees), 3) * deform.dir;
this.vy = ((13 * mcos(this.degrees)) -
(6 * mcos(2 * this.degrees)) - // 5
(2 * mcos(3 * this.degrees)) -
(mcos(deform.a * this.degrees))) * -1;
// update position
this.x = this.vx * this.parent.scalar + this.parent.x;
this.y = this.vy * this.parent.scalar + this.parent.y;
}
function update(){
if(deform.dir === 1){
if(deform.a > deform.min){
deform.a -= deform.s;
}
else{
flipDirection();
}
}
else{
if(deform.a < deform.max){
deform.a += deform.s;
}
else{
flipDirection();
}
}
system.update();
}
function flipDirection(){
deform.dir *= -1;
}
function draw(){
ctx.clearRect(0, 0, width, height);
ctx.save();
for(let i=0; i<system.numParticles; i++){
let p = system.allParticles[i];
ctx.fillStyle = p.colour;
ctx.beginPath();
ctx.arc(p.x, p.y, 1, 0, tau, false);
ctx.fill();
}
ctx.restore();
}
function animate(){
update();
draw();
requestAnimationFrame(animate);
}
let system = new ParticleSystem(pSystemSize);
animate();
</script>
</html>
- OFTest(一):如何忽略一些字段在端口poll报文
- Shiro第二篇【授权、整合Spirng、过滤器】
- Ajax数据的爬取(淘女郎为例)
- 在IDEA中编写Spark的WordCount程序
- Shiro第三篇【授权过滤器、与ehcache整合、验证码、记住我】
- Spark核心RDD、什么是RDD、RDD的属性、创建RDD、RDD的依赖以及缓存、
- Caused by: java.net.ConnectException: Connection refused: master/192.168.3.129:7077
- java.util.zip.ZipException: invalid LOC header (bad signature)
- 递归就这么简单
- Activiti就是这么简单
- WebService就是这么简单
- eclipse中hadoop2.3.0环境部署及在eclipse中直接提交mapreduce任务
- spark on yarn提交任务时一直显示ACCEPTED
- 如何恢复hadoop中被删除的文件
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- c语言二级指针的使用,malloc内存申请
- istio部署模型
- 你所不知道的printf函数
- c语言之——整型的隐式转换与溢出检测
- Istio 的配置分析
- (C99)复合字面量
- 排障集锦:九九八十一难之第十三难!-------------史上最全MySQL 单实例故障排查
- c语言数组越界的避免方法
- 单片机的存储区范例
- 大点干!早点散----------Nginx+Tomcat动静分离
- 大点干!早点散----------深入剖析缓存加速--squid传统代理和透明代理
- stm32 HardFault_Handler调试及问题查找方法——飞思卡尔
- 堆栈的分布
- memset()函数的使用
- 质量保障的方法和实践