一、源码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE> New Document </TITLE><META NAME="Generator" CONTENT="EditPlus"><META NAME="Author" CONTENT=""><META NAME="Keywords" CONTENT=""><META NAME="Description" CONTENT=""><style>html, body {height: 100%;padding: 0;margin: 0;background: #000;
}
canvas {position: absolute;width: 100%;height: 100%;
}
.a{width: 100px;height: 100px;position: absolute;left: 40%;top:25%;
}h3{font-family: 'fangsong';font-size: 6em;color: transparent;}span{display: table-cell;animation: san 3s linear infinite;}h3 span:nth-child(1){animation-delay:0s;}h3 span:nth-child(2){animation-delay:0.1s;} h3 span:nth-child(3){animation-delay:0.2s;}h3 span:nth-child(4){animation-delay:0.3s;}h3 span:nth-child(5){animation-delay:0.4s;}h3 span:nth-child(6){animation-delay:0.5s;}h3 span:nth-child(7){animation-delay:0.6s;}h3 span:nth-child(8){animation-delay:0.7s;}h3 span:nth-child(9){animation-delay:0.8s;}h3 span:nth-child(10){animation-delay:0.9s;}@keyframes san{0%,100%{color: rgb(255, 255, 255);         text-shadow: 0 0 5px rgb(234,128,176),0 0 15px rgb(234,128,176),0 0 25px rgb(234,128,176),0 0 50px rgb(234,128,176),0 0 80px rgb(234,128,176),0 0 120px rgb(234,128,176),0 0 160px rgb(234,128,176),0 0 200px rgb(234,128,176),0 0 300px rgb(234,128,176),0 0 400px rgb(234,128,176),0 0 500px rgb(234,128,176);}20%,80%{color: transparent;text-shadow: none;}}</style></HEAD><BODY><div class="a"><h3><span>喜</span><span>欢</span><span>你</span> </h3></div><canvas id="pinkboard"></canvas><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},
};/** RequestAnimationFrame polyfill by Erik Möller*/
(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></BODY>
</HTML>

二、效果图

【李峋的爱心代码5带文字】相关推荐

  1. 【李峋的爱心代码4】

    一.源码 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3. ...

  2. 点燃我温暖你——李峋的爱心代码

    动态爱心代码❤ <!doctype html> <html> <head> <meta charset="utf-8"> <t ...

  3. 李峋的爱心表白代码来了

    咱啥也不说先上代码 import random from math import sin, cos, pi, log from tkinter import *CANVAS_WIDTH = 1500 ...

  4. 李峋 同款代码,用html来进行表白

    (不要问我李洵是谁,我也不知道他是谁,只是身边的女生都在讨论)不要以为程序员只会埋头写代码,程序员浪漫起来,那也是很浪漫的,下面我们来看一段表白用的代码,这是用html来实现的 <!DOCTYP ...

  5. 【圣诞节特辑】爱心代码(程序员的浪漫plus+)-李峋

    2022年圣诞节到来啦,很高兴这次我们又能一起度过~ 唯有热爱,可抵岁月漫长,唯有热爱,不畏世间无常! 一.前言 前段时间<点燃我温暖你>中李峋的爱心代码超级火,看着特别心动!这不,圣诞节 ...

  6. 【html】理工男李峋的极致浪漫:爱心代码|和你的心跳同频共振

    [写在开头] 不知道发生什么事了?点我 看到最近<点燃我温暖你>中男主角--理工男李峋的爱心代码撩到了无数人,于是把代码开源分享给大家. 哈哈哈,只是长的比较像,李峋的爱心代码你得找李峋去 ...

  7. 《点燃我温暖你》中李峋的同款爱心代码

    前言 最近<点燃我温暖你>中李峋的爱心代码超级火,看着特别心动,这不,光棍节快到了,给兄弟们教学一波爱心代码,赶在双十一前表白,让这个双十一不在是孤单一个人! 目录 前言 Python简易 ...

  8. 李峋同款爱心代码,表白神器!

    背景 最近<点燃我温暖你>中李峋的爱心代码超级火,我在刷b站的时候,偶尔能刷到,然后就点进去看了下,觉得还挺有意思.于是网上搜了一下,挺多复现例子.我找了个看似最火的复现代码,分享一下- ...

  9. 最新复刻李峋爱心表白HTML源代码+超唯美

    正文: 果然没一个人能逃过命韵峋环,李峋的爱心代码真的甜到发昏.(个人感觉这个有点像GIF图"没有断定"没有演示代码的执行过程),是动态的,爱心可以动. 下面是经博主美化后的复刻的 ...

最新文章

  1. 来翻翻百度的老底:当年你是怎么赢的谷歌?
  2. DbHelperSQL.cs
  3. 如何快速解决繁杂的国际化替换
  4. 一个现金流量表的代码
  5. 利用sqoop将hive数据导入导出数据到mysql
  6. java bigdecimal min_java
  7. phpcmsV9怎样在单页中调用后台栏目SEO设置的Meta_title
  8. 字符串 不是有效的 AllXsd 值。
  9. 剑指offer 面试题49. 丑数
  10. php去掉 部分字符,输出,php如何去除某个字符
  11. 【注意力+推荐系统】Attention!当推荐系统遇见注意力机制
  12. 18.go 日志监控系统
  13. 搭建php程序之Linux 安装PHP集成环境宝塔面板
  14. 媒体在计算机科学中的两种含义,多媒体技术应用_思考与练习题.doc
  15. CVE-2013-3893 IE浏览器UAF漏洞分析
  16. RFID 有源,半源和无源的区别
  17. python项目之杠子老虎鸡虫
  18. 戒梭先生:随笔|合格交易者要达到的三个境界
  19. CE-植物大战僵尸-僵尸-关卡-金币
  20. java7找不到uri_部署-Java Jar文件:使用资源错误:URI不是hierarchi

热门文章

  1. IDEA导入scala详解
  2. 中南大学青年志愿者协会电脑维修部
  3. python英文文本分析和提取_英文文本挖掘预处理流程总结
  4. 有奖互动 | 秋天的第一行代码
  5. 超详细:R语言缺失值及异常值处理
  6. 关于线性空间和线性映射
  7. 常见信息泄露类漏洞风险与解决方案
  8. Echarts真正态分布图
  9. Element-UI源码之目录结构
  10. wd移动硬盘不能识别_西部数据移动硬盘无法识别恢复