图例

代码

<!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>

低配版点燃我温暖你爱心代码相关推荐

  1. 点燃我温暖你 爱心代码python

    大家最近有没有看点燃我,温暖你这部剧,陈飞宇扮演的天才编程少年李峋也太帅了吧,那我们就浅浅复刻一下低配版的爱心吧 效果展示如下 工具软件使用Pycharm运行 新建一个new file love.py ...

  2. 跳动的爱心代码,点燃我温暖你爱心代码

    如果能好好被爱,谁不想待在一个人身边一年有一年 创建一个文本,代码粘贴进去,后缀改为html,浏览器打开即可 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HT ...

  3. 实现一个基于 IConfiguration 的低配版 FeatureFlag

    实现一个基于 IConfiguration 的低配版 FeatureFlag Intro 在我们的应用中,可能有一些配置开关的需求,某些功能是否启用使用一个配置开关,用的时候就打开,不用的时候就关掉, ...

  4. 【Node.js】论一个低配版Web实时通信库是如何实现的1( WebSocket篇)

    引论 simple-socket是我写的一个"低配版"的Web实时通信工具(相对于Socket.io),在参考了相关源码和资料的基础上,实现了前后端实时互通的基本功能 选用了Web ...

  5. lga2066服务器准系统,LGA2066低配版Corei7-7740K再曝光:21WTDP换来100MHz频率

    Intel的HEDT高端处理器平台的发布时间从之前的8月份提前到了5月底,台北电脑展上就会正式公布,新一代平台插槽从目前的LGA2011升级到LGA2066,而且会有两个版本--Skylake-X架构 ...

  6. 谷歌 ARCore 就是低配版 Tango,它比苹果 ARKit 好在哪?

    [转] https://www.leiphone.com/news/201709/hioiZlgdXIj9fFex.html 雷锋网按:本文作者为 Matt Miesnieks,目前担任 6D.ai ...

  7. 大神解读:谷歌 ARCore 就是低配版 Tango,它比苹果 ARKit 好在哪?

    转自雷锋网:点击打开链接 原标题:大神解读:谷歌 ARCore 就是低配版 Tango,它比苹果 ARKit 好在哪? 雷锋网按:本文作者为 Matt Miesnieks,目前担任 6D.ai 的 C ...

  8. miix4linux双系统,情理之中,意料之外:Lenovo 联想 MIIX4 平板电脑 低配版

    情理之中,意料之外:Lenovo 联想 MIIX4 平板电脑 低配版 2016-01-27 09:20:17 35点赞 36收藏 53评论 自从我的神舟精盾服役4年之后,终于进入半退役,我一直在等su ...

  9. PS快捷键大法,初级低配版

    在PS中,对于初学者,我个人认为其实不用快捷键更能深刻的理解各个工具.操作之间联系和原理,但对于以后的作图修图来说,快捷键实在是装逼利器,并且确实方便快捷,能给我们的工作带来很多便捷.百度上的PS快捷 ...

最新文章

  1. Angular应用中配置全局路径映射
  2. zabbix之微信告警(python版):微信个人报警,微信企业号告警脚本
  3. 在 Ubuntu 上安装 Android Studio
  4. rss C语言,Android内存:VSS/RSS/PSS/USS介绍
  5. 看我如何作死 | 网络延迟、网络丢包、网络中断一个都没落下过
  6. android list 替换元素_Python数据结构(一)List使用(大厂面试解答)
  7. 全面系统地总结Linux的基本操作(上)
  8. Shell Notes(2)
  9. Android自定义ViewGroup、自定义属性及自定义View
  10. hi35xx stmmac网卡驱动源码解读
  11. 学习自动驾驶技术 学习之路_一天学习驾驶
  12. deebot扫地机器人说明书_ecovacs扫地机器人730使用说明书_deebot扫地机器说明书
  13. 主窗口(10):【类】QWidgetAction [官翻]
  14. MySQL数据库基本命令
  15. 位图矢量化:Potrace的应用
  16. 元器件科普 | 变压器的分类及形状构造
  17. BootLoader启动过程分析
  18. supermap使用idesktop发布二三维管线地图
  19. Hadoop的完全分布式搭建
  20. 你们的哔哩哔哩终于要上市了

热门文章

  1. 前端图像处理之马赛克
  2. 【Dash搭建可视化网站】项目4: 利用Dash Plotly实现数据图表可视化
  3. 【双11背后的技术】AliCloudDB——双11商家后台数据库的基石
  4. Git代码合并之使用 rebase 整理提交历史
  5. OLED TFT屏幕相关
  6. [转]PMP之挣值管理(PV、EV、AC、SV、CV、SPI、CPI)的记忆方法
  7. 北京考虑分时分区单双号限行预期效果遭质疑-北京-分时分区-单双号限行
  8. 个人建设网站流程解说,手把手教你如何在阿里云上搭建自己的网站
  9. WOT讲师杨钊:人工智能将在不同应用场景逐步落地
  10. 百度霸屏引流推广需要多少钱?那么才能霸屏?百度霸屏有什么好处?