1.电脑桌面创建一个后缀名为.txt的记事本文件,把写好的代码复制进去

2.将.txt文本文件另存为 .html 文件并保存,桌面就会出现刚保存的文件(注意是后缀为.html的文件)

3.如果想要修改背景图,可选择一张照片,修改照片名与代码中的一样(图片格式为.jpg)然后将照片和.html页面放在同一个文件夹下即可

4.双击就有想要的效果了

代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE>loveYou</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;background-image: url("pipi.jpg");background-size: contain;width: 100%;height: 100%;}</style>
</HEAD><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>

李峋同款 爱心动态代码 步骤教程,可自定义修改自己喜爱照片背景(附代码)相关推荐

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

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

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

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

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

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

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

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

  5. 【Python】《点燃我,温暖你》李峋同款爱心_python程序

    目录 前言 一.效果展示 二.设备准备 三.代码呈现 前言 偶然在抖音上刷到最近很火的电视剧<点燃我,温暖你>,看到很多人都在网上找源码,侥幸在b站上看见一位up主,简单地复刻了一下. 这 ...

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

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

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

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

  8. 李峋同款爱心代码-电视剧《点燃我温暖你》

    浅浅模仿了一下李峋同款跳动的心,用python完成,引用了tkinter库,最后效果图如图1所示.电视剧里面应该是用AE做的动画(大概率是). """ @author:A ...

  9. HTML李峋同款爱心代码源码分享,手机网页爱心代码源码

    效果图展示 分享一下最近网上很火李峋爱心代码,相似度95%,没电脑的可以去网上搜索能手机运行网页代码的软件,比如webcat.详情自行百度 话不多说,直接上源码: <!DOCTYPE html& ...

最新文章

  1. 深度学习之反向传播算法
  2. mapreduce程序输出评分8.6分以上的书名和评分_如何选编程入门资料?光评分高怎么够|文末赠书...
  3. 如何实现分享网站文章到微信朋友圈时显示指定缩略图或LOGO
  4. 互联网1分钟 | 0914
  5. 简明 Python 教程学习笔记_2_函数
  6. linux 引导管理器,linux系统引导管理器GRUB
  7. poj 1270 Following Orders
  8. 二十年的编程,教会我的五件事!
  9. W3C小组宣布:HTML5标准制定完成
  10. java实现贪吃蛇小游戏(源码+注释)
  11. IMETool 输入法设置工具 十问十答
  12. matlab 矩阵增加行,MATLAB 中 如何在矩阵中插入1行
  13. 《私募股权基金投资基础知识》---第三章
  14. 计算机网络应用层和传输层及网络层协议有哪些?
  15. [UE4]射击产生弹孔:Spawn Decal At Location、Spawn Decal Attached
  16. C# 汉字转拼音 使用微软的Visual Studio International Pack 类库提取汉字拼音首字母...
  17. JavaSE基础笔记(全)
  18. 程序员快速成长的核心原则
  19. 搭建CTPN网络(基于windows与tensorflow)
  20. 币泳金:理安全的储存数字货币,冷钱包与热钱包的管理

热门文章

  1. 关于Java的抽象类与接口
  2. Mysql数据库轻松学06—数据分析师常用:数据查询语言DQL之单表查询
  3. Java基础9----运算符2(关系,逻辑运算符)
  4. 新年伊始 张孝祥老师 离开了
  5. 超级电脑可下载人类思想 究竟是福是祸?(
  6. 山中无甲子,寒尽不知年
  7. 头脑风暴问题:玻璃水果盘的用法
  8. 沉浸式逆向某汽车app
  9. 2分钟实现一个Vue实时直播系统
  10. JS跟APP交互——H5调用原生APP的方法