HTML/樱花爱心网页/

代码如下:

<!DOCTYPE html>
<html><head><title></title><script src="js/jquery.min.js"></script></head><style>* {padding: 0;margin: 0;}html,body {height: 100%;padding: 0;margin: 0;background: #000;}.aa {position: fixed;left: 50%;bottom: 10px;color: #ccc;}.container {width: 100%;height: 100%;}canvas {z-index: 99;position: absolute;width: 100%;height: 100%;}</style><body><!-- 樱花 --><div id="jsi-cherry-container" class="container"><audio autoplay="autopaly"><source src="renxi.mp3" type="audio/mp3" /></audio><img class="img" src="./123.png" alt="" /><!-- 爱心 --><canvas id="pinkboard" class="container"> </canvas></div></body>
</html>
<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},};(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><script>var RENDERER = {INIT_CHERRY_BLOSSOM_COUNT: 30,MAX_ADDING_INTERVAL: 10,init: function () {this.setParameters();this.reconstructMethods();this.createCherries();this.render();if (navigator.userAgent.match(/(phone|pod|iPhone|iPod|ios|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) {// var box = document.querySelectorAll(".box")[0];// console.log(box, "移动端");// box.style.marginTop = "65%";}},setParameters: function () {this.$container = $("#jsi-cherry-container");this.width = this.$container.width();this.height = this.$container.height();this.context = $("<canvas />").attr({ width: this.width, height: this.height }).appendTo(this.$container).get(0)var rate = this.FOCUS_POSITION / (this.z + this.FOCUS_POSITION),x = this.renderer.width / 2 + this.x * rate,y = this.renderer.height / 2 - this.y * rate;return { rate: rate, x: x, y: y };},re}} else {this.phi += Math.PI / (axis.y == this.thresholdY ? 200 : 500);this.phi %= Math.PI;}if (this.y <= -this.renderer.height * this.SURFACE_RATE) {this.x += 2;this.y = -this.renderer.height * this.SURFACE_RATE;} else {this.x += this.vx;this.y += this.vy;}return (this.z > -this.FOCUS_POSITION &&this.z < this.FAR_LIMIT &&this.x < this.renderer.width * 1.5);},};$(function () {RENDERER.init();});</script>

HTML/樱花爱心网页/相关推荐

  1. HTML5 实现动态爱心网页代码

    HTML5 实现动态爱心网页代码 表白女朋友找不到合适的方法?可以试一试动态爱心网页,带你升华感情,一步步走上人生巅峰. 代码如下: <!doctype html> <html> ...

  2. 李峋爱心代码 程序员教你用代码制作爱心网页[樱花+爱心],正好拿去送给女神给她个惊喜

    HTML+CSS+JavaScript实现 先点赞后观看,养成好习惯 效果图 注:任意浏览器都可以,建议使用谷歌浏览器 代码: <!DOCTYPE HTML ><HTML>&l ...

  3. HTML爱心网页制作[樱花+爱心+炫彩文字]

    效果图 代码部分 代码如下仅供参考 可以直接拿去复制粘贴 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN&qu ...

  4. 复制粘贴-实现动态爱心 网页版

    上一篇的python爱心代码有很多读者反馈不会用. 本篇来一个小白版的,无需会代码,有浏览器就可以. 操作步骤 01 复制以下内容,保存为.html文件 (不会保存?先保存为txt文本,然后将后缀改为 ...

  5. 爱心网页浪漫,博主司机搞事情啦,附百度网盘源码自取哦

    刚刚过完了白色情人节,都别酸了,爱情哪有学习重要不是嘛...... 好像我自己也不太信,上天赐予我一个小姐姐!!! 啊,扒拉了几句废话,这篇博客主题偏了,博主主要是想分享一下前辈写的爱心表白网页,好好 ...

  6. 最近很火的爱心网页(html+css+js),表白必备

    一.效果图 二.整体代码 <!DOCTYPE html> <html> <head><title>LOVE</title> </hea ...

  7. HTML爱心网页制作(带文字)

    XXX可随意更改,先点赞后拿文,谢谢大家啦 <!doctype html> <html> <head>     <meta charset="utf ...

  8. 谁说程序员不懂浪漫?动态樱花爱心来咯~ 【附源代码】

    先看效果: 话不多说,直接上代码 可以直接复制粘贴到记事本里面,后缀改为.html保存浏览器打开即可 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4 ...

  9. ❀520七夕情人节告白网页代码❀—浪漫梦幻3D相册(樱花主题)HTML+CSS+JavaScript

    ❀ 520七夕情人节告白网页代码❀-浪漫梦幻3D相册(樱花主题)HTML+CSS+JavaScript 520七夕节告白,也就是中国的情人节,你除了送花你还会什么?? 快来制作高端大气上档次的D立体动 ...

最新文章

  1. 神秘AI换脸软件入侵全球社交网络!马斯克秒变文艺复兴贵族
  2. U盘从4G变为了75M 恢复U盘容量的方法
  3. 海口只有阳光沙滩?错,人家还是“最佳智慧城市”
  4. Java 入门基础——面向对象的特征
  5. php面向对象异常处理,PHP面向对象编程——自定义PHP异常处理类
  6. html 移动app开发
  7. 【李宏毅2020 ML/DL】P10 Classification_1 | 简单的例子告诉你使用 wx+b 以及 Sigmoid 作为激活函数的合理性
  8. 2018-2019-1 20165307 20165327 20165332 实验二 固件程序设计
  9. 【渝粤题库】陕西师范大学800003 中国地理
  10. inDesign教程,如何共享inDesign文件?
  11. 飞猪平台用户行为分析—python
  12. ESP8266+blinker测温湿度
  13. 港科夜闻|香港科技大学参与共建「粤港水安全保障联合实验室」,开展水资源风险评估等方面交叉研究和成果转化...
  14. Svelte-Ui-Admin基于svelte-ui中后台管理系统|Svelte3+Vite3后台框架
  15. QQ的在线拼音输入法
  16. java2d游戏代码_Java 2d游戏中的“JUMP”
  17. 最新传奇木马及其防范全攻略
  18. Android kotlin 实现一键清理内存功能
  19. 解锁智能名片具备的九大因素,让选择更加明确
  20. Java学习的第六天

热门文章

  1. 联想Y50耳机插入耳机孔后没有声音解决办法
  2. Excel数据查重小技巧
  3. Pytorch dataloader中的num_workers (选择最合适的num_workers值)
  4. 关于Web的欢迎页面的开发设置
  5. Τεχνική υποστήριξη
  6. 学习树莓派的几个推荐站点
  7. xv6 6.S081 Lab3: alloc
  8. 真正的人品,藏在对弱者的态度里
  9. Nothing——for 情人节
  10. 周文上海大学计算机学院,上海大学计算机工程与科学学院硕士生导师周文