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

<!DOCTYPE html>
<html>
<head><title></title>
</head>
<style>*{padding: 0;margin: 0;}html, body {height: 100%;padding: 0;margin: 0;background: #000;
}
canvas {position: absolute;width: 100%;height: 100%;
}
.aa{position: fixed;left: 50%;bottom: 10px;color: #ccc
}
</style>
<body><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>

我们来看看效果

代码并不是本人原创,若有侵权,可以联系删除

李峋 同款代码,用html来进行表白相关推荐

  1. 李峋同款爱心代码【有声版】

    一.工具准备 1.安装Pycharm 1.1双击pycharm-professional-2020.1.exe一直下一步即可. 1.2将图中所框目录放到桌面(脚本有需要的评论留言) 1.3双击图中所框 ...

  2. 214 情人节来袭,电视剧 《点燃我温暖你》李峋同款 Python爱心表白代码,赶紧拿去用吧

    大家好,我是徐公,六年大厂程序员经验,今天为大家带来的是动态心形代码,电视剧 <点燃我温暖你>同款的,大家赶紧看看,拿去向你心仪的对象表白吧,下面说一下灵感来源. 灵感来源 今天,早上起来 ...

  3. 李峋同款爱心代码(附源码)

    李峋同款浪漫爱心代码(快拿去给爸爸妈妈,给男(女)朋友看!!!) 基于新建文件基础上.txt文档 <html> <head><meta charset="utf ...

  4. HTML文本抖音李峋同款爱心代码超好看

    热播剧李峋的超炫爱心代码同款,让你现实中感受电视剧情节,拿去感受感受计算机天才的魅力吧~ 代码展示 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4. ...

  5. 李峋同款爱心代码(附源码,前端代码,python代码)

    Hello 大家好 如何浪漫的表白,作为程序员出身的小编,今天就带你实现热播剧<点燃我,温暖你>中超火的李峋同款爱心代码!前面是教程,怕麻烦的朋友可以直接划到文末,下载现成的,下载完成后打 ...

  6. 李峋同款爱心代码 (超好看) | 电视剧《点燃我温暖你》

    李峋同款爱心代码 (超好看) | 电视剧<点燃我温暖你> 废话不多说,上代码: import random from math import sin, cos, pi, log from ...

  7. 李峋同款会动的爱心Python代码版

    最近看到不少关于李峋同款爱心的视频.文章,今天我们也分享一下李峋同款爱心 Python 代码版.要问李峋是谁?我也不太清楚,大家可自行百度,这个是我百度的结果,仅供参考. 简单来说李峋同款爱心就是一个 ...

  8. 李峋同款心跳Python代码

    李峋同款心跳Python代码[按头安利<点燃我温暖你>] import random from math import sin,cos,pi,log from tkinter import ...

  9. Python版李峋同款爱心代码来了!!

    李峋是谁?我也不太清楚! 但是最近看到不少关于李峋同款爱心的视频和文章 今天也来分享一下李峋同款爱心的相关代码,如下! import random from math import sin, cos, ...

最新文章

  1. 3D Slicer画病灶可能产生的问题+核磁共振影像数据处理-14-3d slicer画病灶“三宗罪”|常见bug(错误)汇总
  2. oracle apex接口文件,Oracle之APEX深入开发指南
  3. BZOJ 1016 最小生成树计数
  4. 团队-团队编程项目作业名称-成员简介及分工
  5. vc开发soap客户端(方式一)
  6. Zynq SOC学习笔记之设备树
  7. C# 以管理员身份运行WinForm程序
  8. C#各版本新增加功能
  9. 域名授权系统源码 网站源码授权系统_单域名授权系统
  10. Spring MVC防御CSRF、XSS和SQL注入攻击
  11. operator* operator- 操作符的使用
  12. python自动测试模型_Selenium+Python 自动化测试模型
  13. python趋势回归_Python 回归分析 - 树懒学堂
  14. SVN 与CVS 和VSS的区别
  15. head first 设计模式源码
  16. EDA第一次课<1117电路图的绘制>
  17. C语言的文件读写函数
  18. Python从excel读取数据并绘图
  19. IP协议及IPV4地址
  20. 【TPAMI 2022】A Survey on Vision Transformer

热门文章

  1. [读论文]语言视觉多模态预训练模型 ViLBERT
  2. Word 2016 通过尾注插入参考文献和修改尾注编码方式:
  3. mysql 导出建库_mysql 安装、建库、导入导出数据
  4. 山东大学软件学院2022年春操作系统期末考试
  5. padStart is not a function
  6. 正则化理解+负采样理解以及神经网络中的负采样
  7. DAG vs. MPP
  8. python训练模型、如何得到模型训练总时长_模型训练时间的估算
  9. 动态规划进阶题目之货币面值
  10. 抽象数据类型 (ADT)