html爱心代码

 此处填写你爱人的名字

代码

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body>
<!doctype html>
<html>
<head><meta charset="utf-8"><title>爱心</title><!-- 这是网页标题 --><style>body{overflow: hidden;margin: 0;}h1{position: fixed;top: 30%;left: 0;width: 100%;text-align: center;transform:translateY(-50%);font-family: 'Love Ya Like A Sister', cursive;font-size: 60px;color: #c70012;padding: 0 20px;}h1 span{position: fixed;left: 0;width: 100%;text-align: center;margin-top:30px;font-size:40px;}</style>
</head>
<body>
<h1 id="h1"></h1>
<canvas></canvas> <!--canvas 画布-->
<script>var canvas = document.querySelector("canvas"),ctx = canvas.getContext("2d");var ww,wh;function onResize(){ww = canvas.width = window.innerWidth;wh = canvas.height = window.innerHeight;}ctx.strokeStyle = "red";ctx.shadowBlur = 25;ctx.shadowColor = "hsla(0, 100%, 60%,0.5)";var precision = 100;var hearts = [];var mouseMoved = false;function onMove(e){mouseMoved = true;if(e.type === "touchmove"){hearts.push(new Heart(e.touches[0].clientX, e.touches[0].clientY));hearts.push(new Heart(e.touches[0].clientX, e.touches[0].clientY));}else{hearts.push(new Heart(e.clientX, e.clientY));hearts.push(new Heart(e.clientX, e.clientY));}}var Heart = function(x,y){this.x = x || Math.random()*ww;this.y = y || Math.random()*wh;this.size = Math.random()*2 + 1;this.shadowBlur = Math.random() * 10;this.speedX = (Math.random()+0.2-0.6) * 8;this.speedY = (Math.random()+0.2-0.6) * 8;this.speedSize = Math.random()*0.05 + 0.01;this.opacity = 1;this.vertices = [];for (var i = 0; i < precision; i++) {var step = (i / precision - 0.5) * (Math.PI * 2);var vector = {x : (15 * Math.pow(Math.sin(step), 3)),y : -(13 * Math.cos(step) - 5 * Math.cos(2 * step) - 2 * Math.cos(3 * step) - Math.cos(4 * step))}this.vertices.push(vector);}}Heart.prototype.draw = function(){this.size -= this.speedSize;this.x += this.speedX;this.y += this.speedY;ctx.save();ctx.translate(-1000,this.y);ctx.scale(this.size, this.size);ctx.beginPath();for (var i = 0; i < precision; i++) {var vector = this.vertices[i];ctx.lineTo(vector.x, vector.y);}ctx.globalAlpha = this.size;ctx.shadowBlur = Math.round((3 - this.size) * 10);ctx.shadowColor = "hsla(0, 100%, 60%,0.5)";ctx.shadowOffsetX = this.x + 1000;ctx.globalCompositeOperation = "screen"ctx.closePath();ctx.fill()ctx.restore();};function render(a){requestAnimationFrame(render);hearts.push(new Heart())ctx.clearRect(0,0,ww,wh);for (var i = 0; i < hearts.length; i++) {hearts[i].draw();if(hearts[i].size <= 0){hearts.splice(i,1);i--;}}}onResize();window.addEventListener("mousemove", onMove);window.addEventListener("touchmove", onMove);window.addEventListener("resize", onResize);requestAnimationFrame(render);window.οnlοad=function starttime(){time(h1,'2022,2,1');     // 2021年春节时间ptimer = setTimeout(starttime,1000); // 添加计时器}</script></body>
</html>
<!DOCTYPE html>
<html>
<head><title></title><script src="js/jquery.min.js"></script>
</head>
<style>* {padding: 0;margin: 0;}html,body {height: 100%;padding: 0;margin: 0;background: #000;}.aa {position: fixed;left: 50%;bottom: 10px;color: #ccc;}.container {width: 100%;height: 100%;}canvas {z-index: 99;position: absolute;width: 100%;height: 100%;}#juzhong{position: absolute;left: 50%;top: 50%;}
</style>
<body>
<!-- 樱花 -->
<div id="jsi-cherry-container" class="container"><div id="juzhong" ><!-- 填写名字 --><font color="hotpink"></font>></div><audio autoplay="autopaly"><source src="renxi.mp3" type="audio/mp3" /></audio><img class="img" src="./123.png" alt="" /><!-- 爱心 --><canvas id="pinkboard" class="container"></canvas>
</div></body>
</html>
<script>/** Settings*/var settings = {particles: {length: 500, // maximum amount of particlesduration: 2, // particle duration in secvelocity: 100, // particle velocity in pixels/seceffect: -0.75, // play with this for a nice effectsize: 30, // particle size in pixels},};(function () {var b = 0;var c = ["ms", "moz", "webkit", "o"];for (var a = 0; a < c.length && !window.requestAnimationFrame; ++a) {window.requestAnimationFrame = window[c[a] + "RequestAnimationFrame"];window.cancelAnimationFrame =window[c[a] + "CancelAnimationFrame"] ||window[c[a] + "CancelRequestAnimationFrame"];}if (!window.requestAnimationFrame) {window.requestAnimationFrame = function (h, e) {var d = new Date().getTime();var f = Math.max(0, 16 - (d - b));var g = window.setTimeout(function () {h(d + f);}, f);b = d + f;return g;};}if (!window.cancelAnimationFrame) {window.cancelAnimationFrame = function (d) {clearTimeout(d);};}})();/**Point class*/var Point = (function () {function Point(x, y) {this.x = typeof x !== "undefined" ? x : 0;this.y = typeof y !== "undefined" ? y : 0;}Point.prototype.clone = function () {return new Point(this.x, this.y);};Point.prototype.length = function (length) {if (typeof length == "undefined")return Math.sqrt(this.x * this.x + this.y * this.y);this.normalize();this.x *= length;this.y *= length;return this;};Point.prototype.normalize = function () {var length = this.length();this.x /= length;this.y /= length;return this;};return Point;})();/** Particle class*/var Particle = (function () {function Particle() {this.position = new Point();this.velocity = new Point();this.acceleration = new Point();this.age = 0;}Particle.prototype.initialize = function (x, y, dx, dy) {this.position.x = x;this.position.y = y;this.velocity.x = dx;this.velocity.y = dy;this.acceleration.x = dx * settings.particles.effect;this.acceleration.y = dy * settings.particles.effect;this.age = 0;};Particle.prototype.update = function (deltaTime) {this.position.x += this.velocity.x * deltaTime;this.position.y += this.velocity.y * deltaTime;this.velocity.x += this.acceleration.x * deltaTime;this.velocity.y += this.acceleration.y * deltaTime;this.age += deltaTime;};Particle.prototype.draw = function (context, image) {function ease(t) {return --t * t * t + 1;}var size = image.width * ease(this.age / settings.particles.duration);context.globalAlpha = 1 - this.age / settings.particles.duration;context.drawImage(image,this.position.x - size / 2,this.position.y - size / 2,size,size);};return Particle;})();/** ParticlePool class*/var ParticlePool = (function () {var particles,firstActive = 0,firstFree = 0,duration = settings.particles.duration;function ParticlePool(length) {// create and populate particle poolparticles = new Array(length);for (var i = 0; i < particles.length; i++)particles[i] = new Particle();}ParticlePool.prototype.add = function (x, y, dx, dy) {particles[firstFree].initialize(x, y, dx, dy);// handle circular queuefirstFree++;if (firstFree == particles.length) firstFree = 0;if (firstActive == firstFree) firstActive++;if (firstActive == particles.length) firstActive = 0;};ParticlePool.prototype.update = function (deltaTime) {var i;// update active particlesif (firstActive < firstFree) {for (i = firstActive; i < firstFree; i++)particles[i].update(deltaTime);}if (firstFree < firstActive) {for (i = firstActive; i < particles.length; i++)particles[i].update(deltaTime);for (i = 0; i < firstFree; i++) particles[i].update(deltaTime);}// remove inactive particleswhile (particles[firstActive].age >= duration &&firstActive != firstFree) {firstActive++;if (firstActive == particles.length) firstActive = 0;}};ParticlePool.prototype.draw = function (context, image) {// draw active particlesif (firstActive < firstFree) {for (i = firstActive; i < firstFree; i++)particles[i].draw(context, image);}if (firstFree < firstActive) {for (i = firstActive; i < particles.length; i++)particles[i].draw(context, image);for (i = 0; i < firstFree; i++) particles[i].draw(context, image);}};return ParticlePool;})();/** Putting it all together*/(function (canvas) {var context = canvas.getContext("2d"),particles = new ParticlePool(settings.particles.length),particleRate =settings.particles.length / settings.particles.duration, // particles/sectime;// get point on heart with -PI <= t <= PIfunction pointOnHeart(t) {return new Point(160 * Math.pow(Math.sin(t), 3),130 * Math.cos(t) -50 * Math.cos(2 * t) -20 * Math.cos(3 * t) -10 * Math.cos(4 * t) +25);}// creating the particle image using a dummy canvasvar image = (function () {var canvas = document.createElement("canvas"),context = canvas.getContext("2d");canvas.width = settings.particles.size;canvas.height = settings.particles.size;// helper function to create the pathfunction to(t) {var point = pointOnHeart(t);point.x =settings.particles.size / 2 +(point.x * settings.particles.size) / 350;point.y =settings.particles.size / 2 -(point.y * settings.particles.size) / 350;return point;}// create the pathcontext.beginPath();var t = -Math.PI;var point = to(t);context.moveTo(point.x, point.y);while (t < Math.PI) {t += 0.01; // baby steps!point = to(t);context.lineTo(point.x, point.y);}context.closePath();// create the fillcontext.fillStyle = "#ea80b0";context.fill();// create the imagevar image = new Image();image.src = canvas.toDataURL();return image;})();// render that thing!function render() {// next animation framerequestAnimationFrame(render);// update timevar newTime = new Date().getTime() / 1000,deltaTime = newTime - (time || newTime);time = newTime;// clear canvascontext.clearRect(0, 0, canvas.width, canvas.height);// create new particlesvar amount = particleRate * deltaTime;for (var i = 0; i < amount; i++) {var pos = pointOnHeart(Math.PI - 2 * Math.PI * Math.random());var dir = pos.clone().length(settings.particles.velocity);particles.add(canvas.width / 2 + pos.x,canvas.height / 2 - pos.y,dir.x,-dir.y);}// update and draw particlesparticles.update(deltaTime);particles.draw(context, image);}// handle (re-)sizing of the canvasfunction onResize() {canvas.width = canvas.clientWidth;canvas.height = canvas.clientHeight;}window.onresize = onResize;// delay rendering bootstrapsetTimeout(function () {onResize();render();}, 10);})(document.getElementById("pinkboard"));
</script><script>var RENDERER = {INIT_CHERRY_BLOSSOM_COUNT: 30,MAX_ADDING_INTERVAL: 10,init: function () {this.setParameters();this.reconstructMethods();this.createCherries();this.render();if (navigator.userAgent.match(/(phone|pod|iPhone|iPod|ios|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) {// var box = document.querySelectorAll(".box")[0];// console.log(box, "移动端");// box.style.marginTop = "65%";}},setParameters: function () {this.$container = $("#jsi-cherry-container");this.width = this.$container.width();this.height = this.$container.height();this.context = $("<canvas />").attr({ width: this.width, height: this.height }).appendTo(this.$container).get(0)var rate = this.FOCUS_POSITION / (this.z + this.FOCUS_POSITION),x = this.renderer.width / 2 + this.x * rate,y = this.renderer.height / 2 - this.y * rate;return { rate: rate, x: x, y: y };},re}} else {this.phi += Math.PI / (axis.y == this.thresholdY ? 200 : 500);this.phi %= Math.PI;}if (this.y <= -this.renderer.height * this.SURFACE_RATE) {this.x += 2;this.y = -this.renderer.height * this.SURFACE_RATE;} else {this.x += this.vx;this.y += this.vy;}return (this.z > -this.FOCUS_POSITION &&this.z < this.FAR_LIMIT &&this.x < this.renderer.width * 1.5);},};$(function () {RENDERER.init();});
</script></body>
</html>

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/434798.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

分享制作精良的知识管理系统 配置SQL Server文档数据库 完美实现博客文章的的下载,存储和浏览...

前一篇文章《分享制作精良的知识管理系统 博客备份程序 Site Rebuild》已经提到如何使用Site Rebuild来下载您所喜欢的博客文章&#xff0c;但是还不能实现把下载的文件导入进数据库中&#xff0c;无法实现在线浏览服务器中的文档数据。这一篇文章则帮助您建立文档数据库&#…

python绘制敏感性和特异性曲线(交叉)

示例 代码如下 test_fpr, test_tpr, test_thresholds roc_curve(y_test_two, dataset_blend_test_pred, pos_label1) test_roc_auc auc(test_fpr, test_tpr) plt.plot(test_thresholds, 1-test_fpr, labelspecificity) plt.plot(test_thresholds, test_tpr, labelsensitivit…

一个网络资深者发起的思考

陈硕 (giantchen AT gmail) blog.csdn.net/Solstice 前几天我在新浪微博上出了两道有关 TCP 的思考题&#xff0c;引发了一场讨论 http://weibo.com/1701018393/eCuxDrta0Nn 。 第一道初级题目是&#xff1a; 有一台机器&#xff0c;它有一个 IP&#xff0c;上面运行了一个 TCP…

C++课堂整理--第一章内容

提前声明&#xff1a; 本文内容为华北水利水电大学研究生C课程&#xff0c;如有 侵权请告知&#xff0c;作者会予以删除 1.C特点 1.历史悠久。2.应用广泛。3.兼容c。4.面向对象。5.适合编写系统程序。6.有助于理解计算机的工作过程&#xff0c;深入理解计算机的原理和概念 …

oauth2 access_denied 不允许访问_OAuth 2 是什么-入门介绍

OAuth 2是什么OAuth 2是一个可以通过浏览器&#xff0c;手机等多种设备进行安全授权的一个标准简单的开源协议。随着互联网的兴起以及普及&#xff0c;越来越多的应用出现在用户的面前。这些应用大部分都是相对独立的以及由不同的公司进行运营的。不同的应用也保存了不同的数据…

基于TCP协议的网络程序(基础学习)

下图是基于TCP协议的客户端/服务器程序的一般流程&#xff1a; 图 37.2. TCP协议通讯流程 服务器调用socket()、bind()、listen()完成初始化后&#xff0c;调用accept()阻塞等待&#xff0c;处于监听端口的状态&#xff0c;客户端调用socket()初始化后&#xff0c;调用connect(…

一段代码认识C++中const不同位置的用处

#include<iostream> using namespace std ; int main () { const int A 78 ;const int B 25 ;int C 13 ;//---------const在数据类型前-------------------- const int *pi &A ;//*pi 56 ;// 错误, 不能修改所指常量。此时*pi指向的是常量A。 pi &…

wcf系列学习5天速成——第五天 服务托管

今天是系列的终结篇&#xff0c;当然要分享一下wcf的托管方面的知识。 wcf中托管服务一般有一下四种&#xff1a; Console寄宿&#xff1a; 利于开发调试&#xff0c;但不是生产环境中的最佳实践。 winform寄宿&#xff1a; 方便与用户进行交互&#x…

ASP.NET MVC Music Store教程(2):控制器

ASP.NET MVC Music Store教程&#xff08;2)&#xff1a;控制器 转自http://firechun.blog.163.com/blog/static/3180452220110272197830/在传统的Web架构中&#xff0c;URL总是映射到磁盘上的文件。例如&#xff1a;一个类似于“/Products.aspx”或“/Products.php”的URL可能…

C语言:利用泰勒级数计算sinx的值

题目&#xff1a; 代码&#xff1a; #include<stdio.h> #include<math.h> int main(){int sign1,n1;double x3,term,a,sinx0;//scanf("%lf",&x);termx;while(fabs(term)>0.00001){sinxsign*term;nn2;apow(x,n);double b1;for(int i1;i<n;i){…

C++课堂整理--第二章内容

提前声明&#xff1a; 本文内容为华北水利水电大学研究生C课程&#xff0c;如有 侵权请告知&#xff0c;作者会予以删除 1程序控制结构 语句是程序的基本语法成分。程序设计语言的语句按功能可以分成三类&#xff1a;声明语句 指示编译器分配内存&#xff0c;或者提供程序…

我的电脑 III

耳机用的是飞利浦的&#xff0c;和上学那时候的差不多 老的那个睡觉的时候压碎了&#xff0c;我胖了 然后去找音箱 网店&#xff0c;专卖店&#xff0c;电脑城&#xff0c;走了一遍又一遍 没个看的上的 一个月以后&#xff0c;终于决定买飞利浦那个了 白色的&#xff0c;和整个…

mybatis删除成功返回0_你还在用分页?试试 MyBatis 流式查询,真心强大!

转自&#xff1a;捏造的信仰segmentfault.com/a/1190000022478915基本概念流式查询指的是查询成功后不是返回一个集合而是返回一个迭代器&#xff0c;应用每次从迭代器取一条查询结果。流式查询的好处是能够降低内存使用。如果没有流式查询&#xff0c;我们想要从数据库取 1000…

C++程序设计--第三章内容

提前声明&#xff1a; 本文内容为华北水利水电大学研究生C课程&#xff0c;如有 侵权请告知&#xff0c;作者会予以删除 1.函数 函数作用 —— 任务划分&#xff1b;代码重用定义形式 类型 函数名 &#xff08; 形式参数表&#xff09;{语句序列}调用形式 函数名&#x…

Linux TCP server系列(5)-select模式下的单进程server

目标&#xff1a; 让服务器退化为单进程模式&#xff0c;但是利用select来提升性能 思路&#xff1a; &#xff08;1&#xff09;服务器 传统的单进程服务器一旦accept了客户端的TCP连接后&#xff0c;就转入客户请求的处理&#xff0c;处理完成后才能再一次的调用…

替换元素_80%的前端会答错的问题:lt;imggt;是什么元素?

前言某天晚上&#xff0c;和几个朋友去撸串&#xff0c;突然就聊到了面试&#xff0c;都在感叹现在的面试题太变态了&#xff0c;其中一个突然很神秘的问我&#xff1a;“你写前端这么久了&#xff0c;那你知道 <img> 是什么元素吗&#xff1f;”于是我结合平时写页面的经…

用指针变量访问数组

一维指针 地址值 a 相当于 & a[ 0 ] a 1 相当于 & a[ 1 ] a 2 相当于 & a[ 2 ] a i 相当于 & a[ i ] 元素值 a [ 0 ] * a a [ 1 ] 相当于 * ( a 1 ) a [ 2 ] 相当于 * ( a 2 ) a [ i ] 相当于 * ( a i ) 二维 用指…

Linux TCP server系列(6)-select模式下的多线程server

目标&#xff1a; 修改上一篇的select模式下的server&#xff0c;让它使用多线程来处理客户端请求&#xff08;多进程的模式已经在上篇中加了注释&#xff09;。 思路&#xff1a; &#xff08;1&#xff09;服务器 我们已经在之前的客户端模型多个并发用户的过程中使用过多线程…

单选按钮_PerlTk教程之按钮Button、复选按钮Checkbutton、单选按钮Radiobutton(附完整代码)...

《Perl-Tk教程之按钮Button、复选按钮Checkbutton、单选按钮Radiobutton》Perl-Tk中有三种不同形式的按钮组件可供选择&#xff0c;它们分别是按钮(Button), 复选按钮(Checkbutton), 和单选按钮(Radiobutton)&#xff0c;如下图所示&#xff1a;这三种按钮看起来是不同的&#…

好奇怪呀后面加什么标点_狗狗吃饭时奇怪的小动作,你知道代表什么吗?做个懂狗的好主人...

狗狗有时候因为一些奇怪的小行为&#xff0c;会让主人觉得很可爱。如果我们希望能够了解狗狗更多一些&#xff0c;那么我们需要透过它们的行为本身&#xff0c;去理解背后所代表的含义&#xff0c;才能和狗狗更亲密的交流。很多狗狗在吃饭的时候&#xff0c;也会表现出一些奇奇…