点燃你温暖我 爱心 源码
复制到txt中,后缀改为html,双击运行就好啦,是动态的!!!!!
<!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%;
}</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>
源码链接:
https://gitee.com/qq209364619/hearts/blob/master/hearts.html#
点燃你温暖我 爱心 源码相关推荐
- 点燃我温暖你 爱心代码python
大家最近有没有看点燃我,温暖你这部剧,陈飞宇扮演的天才编程少年李峋也太帅了吧,那我们就浅浅复刻一下低配版的爱心吧 效果展示如下 工具软件使用Pycharm运行 新建一个new file love.py ...
- 跳动的爱心代码,点燃我温暖你爱心代码
如果能好好被爱,谁不想待在一个人身边一年有一年 创建一个文本,代码粘贴进去,后缀改为html,浏览器打开即可 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HT ...
- 低配版点燃我温暖你爱心代码
图例 代码 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML>< ...
- 214 情人节来袭,电视剧 《点燃我温暖你》李峋同款 Python爱心表白代码,赶紧拿去用吧
大家好,我是徐公,六年大厂程序员经验,今天为大家带来的是动态心形代码,电视剧 <点燃我温暖你>同款的,大家赶紧看看,拿去向你心仪的对象表白吧,下面说一下灵感来源. 灵感来源 今天,早上起来 ...
- HTML5一个浪漫的程序猿:3D旋转爱心表白神器思路源码视频
源码/视频评论后加前端学习群470593776 javascript课题:3D旋转爱心表白神器 知识点:CSS3变换.3D场景运用,3D立方体制作技巧,爱心制作技巧, 原生js DOM操作,逻辑思维锻 ...
- Unity+SenseAR教程 | 用手势发射爱心2:加入发射方向【源码】
摘要:Unity+SenseAR2.3开发的AR应用,基于手势识别同时计算手势方向,发射你的爱心~ 洪流学堂,让你快人几步.你好,我是你的技术探路者郑洪智,你可以叫我大智. 这篇教程是为了填上一篇教程 ...
- Unity+SenseAR教程:用手势发射爱心【源码】
摘要:Unity+SenseAR2.3开发的AR应用,基于手势识别功能,发射你的爱心~ 洪流学堂,让你快人几步.你好,我是你的技术探路者郑洪智,你可以叫我大智. 今天开头就不絮叨了,一句"名 ...
- HTML李峋同款爱心代码源码分享,手机网页爱心代码源码
效果图展示 分享一下最近网上很火李峋爱心代码,相似度95%,没电脑的可以去网上搜索能手机运行网页代码的软件,比如webcat.详情自行百度 话不多说,直接上源码: <!DOCTYPE html& ...
- 《点燃我温暖你》中李峋的同款爱心代码
前言 最近<点燃我温暖你>中李峋的爱心代码超级火,看着特别心动,这不,光棍节快到了,给兄弟们教学一波爱心代码,赶在双十一前表白,让这个双十一不在是孤单一个人! 目录 前言 Python简易 ...
最新文章
- Palm pre,我的M8又要落伍了
- 办公出口ip多个地址_如何正确分配与高效管理IP地址
- 过程或函数的副作用是_Python函数和函数式编程(两万字长文警告!一文彻底搞定函数,建议收藏!)...
- ARMA模型的性质之ARMA模型
- 解读金融高频交易不出错的金手指:分布式事务管理
- React Native状态机和应用设计思路
- CocosCreator中TiledMap简单使用
- Unity3d 周分享(22期 2019.8.30 )
- 【水题】CodeForce 1183A
- MapReduce之Partition分区实例操作
- Android保存图片和视频到相册
- Dewplayer MP3网页播放器
- Win10点击PowerShell显示找不到文件路径
- beyond compare java_文件内容比较工具---Text compare Beyond compare
- JSP校园运动会管理系统
- 爆聚美优品售假货,中国老龄商城有话说
- 智慧工地解决方案的关键技术
- 树莓派4B入手体验及配置
- 这一年,半导体行业风云变幻
- 岗位认识---算法工程师、数据分析
热门文章
- Cross Stage Partial Network(CSPNet)
- 人机界面的系统是Linux吗,西门子人机界面(HMI)和plc人机界面系统区别介绍
- 版本管理之gitlab实践教程:基础篇(3)
- 华为云FusionInsight MRS容灾:大数据两地三中心的容灾也可以如此省心
- 【Latex】Texstudio英文拼写错误检查功能出问题的解决方法
- 服务器的内存和硬盘哪个更重要,[内存与硬盘区别] 内存和硬盘哪个重要
- 如何让淘宝店铺排名更靠前 淘宝搜索排名技巧分享
- ifm电感式传感器IE5238
- Java中正则表达式的使用
- 贪心:Fence Repair、Saruman's Army