上一篇的python爱心代码有很多读者反馈不会用。

本篇来一个小白版的,无需会代码,有浏览器就可以。

操作步骤

01 复制以下内容,保存为.html文件

(不会保存?先保存为txt文本,然后将后缀改为.html)

02  双击该文件,打开即可出现动态爱心

代码如下:

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

太单调?想要加文案?

定制升级版(可以自定义姓名及文案)

复制粘贴-实现动态爱心 网页版相关推荐

  1. vue 动态变量名_【告别复制粘贴】动态模板生成小技巧

    ? 这是第 75篇不掺水的原创,想要了解更多,请戳上方蓝色字体:政采云前端团队关注我们吧- 本文首发于政采云前端团队博客:告别复制粘贴:动态模板生成小技巧 https://www.zoo.team/a ...

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

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

  3. html网页文档无法复制粘贴图片,网页文本无法复制粘贴?高手教的这5招太绝了,全网任意免费复制!...

    说到网页的复制粘贴,相信很多人都有过这种经历: 办公时经常需要在网上查找资料,然而好不容易找到了找到了不错的资料,想复制粘贴时却因为网页本身的限制,导致无法复制! 那么,在网上遇到一些无法复制的文本时 ...

  4. 复制+粘贴->集群就绪 | 微软视角hpc4you_toolkit使用演示

    最新更新 2022年8月28日再次改进. 也许是我自己使用Linux太久了, 实在无法理解, 为何总有人抱怨, 上传文件后, 找不到文件在哪里? 问题是, 文件是你自己上传的, 我怎么晓得文件在哪里? ...

  5. 第十八期:网页禁止复制粘贴怎么办?教你六招轻松搞定

    经常在网上遇到一些无法复制的文章,那么问题来了,有什么办法可以绕开这种限制,将网页内容轻松下载回来呢? 经常在网上遇到一些无法复制的文章,那么问题来了,有什么办法可以绕开这种限制,将网页内容轻松下载回 ...

  6. 禁止复制粘贴_网页禁止你复制粘贴?新同事教我这三招,全网内容随我复制

    我们平常经常需要在网上查找资料,但是由于网站的限制,网页的内容经常没办法复制粘贴,只能自己一个字一个字手打,但这样效率实在太慢了,今天新同事教了我三个方法,轻松就可以直接复制网页内容,想复制哪里就复制 ...

  7. AE图片跨软件复制粘贴扩展脚本 Copy Pasta for Mac 破解版

    Copy Pasta for Mac 破解版是一款ae图片跨软件复制粘贴扩展插件,可以快速复制当前帧图片到剪切板,粘贴到任意软件:如AI,PS,ID等软件,当然也可以复制到QQ,而且可以在浏览网页,右 ...

  8. 网页禁止复制粘贴怎么办?教你六招轻松完成

    文章目录 前言 方法一. 手机拍照识别 方法二. 切换IE内核 方法三. 查看源代码 方法四. 保存网页格式 方法五. 打印法 方法六. 插件法 写在最后 前言 经常在网上遇到一些无法复制的文章,那么 ...

  9. 网页禁止复制粘贴怎么办?教你六招轻松搞定

    资讯内容 经常在网上遇到一些无法复制的文章,那么问题来了,有什么办法可以绕开这种限制,将网页内容轻松下载回来呢?其实既然是网页内容,那么意味着HTML代码是公开的,将相关文本复制下来根本不是问题,一起 ...

最新文章

  1. 比特币现金成为第二个最有价值的区块链
  2. [转载]玩转Asp.net MVC 的八个扩展点
  3. 黑顶帽—lhMorpBlackTopHat
  4. python 读中文乱码_python字符乱码的解决小结
  5. 刚刚!6月榜单:JS跌惨,Python又霸榜,C++再无翻身可能!
  6. graphpad prism画折线图_如何用Graphpad Prism 8作折线图
  7. rnn神经网络模型_ICLR 2019 | 与胶囊网络异曲同工:Bengio等提出四元数循环神经网络...
  8. 解决安卓TextView高度和textSize大小不一致问题
  9. HDU 4622 求解区间字符串中的不同子串的个数
  10. python 覆盖list_这套python 面试题你还没有?保证让你面试通关《附Python源码+实战项目》...
  11. php 可选表格,PHP_表格标记,  ■ 表格标记 TABLE - phpStudy
  12. 免费送《你的知识需要管理》签名书活动,秒杀
  13. System.Web.AspNetHostingPermission 类型的权限已失败
  14. C语言scanf输入a3,【C语言】04 printf和scanf函数
  15. Java Drool规则引擎
  16. Angular Mock Data
  17. c 语言ifelse语句的用法,C 语言 if...else 语句
  18. 老男孩python全栈视频教程_老男孩Python全栈7期,Flask全套组件及原理剖析视频教程下载...
  19. MPAndroidChart 3.0——BarChart(一)
  20. 计算机主机只有一块硬盘,电脑双硬盘只显示一个怎么办

热门文章

  1. 用中文把玩Google开源的Deep-Learning项目word2vec
  2. 星巴克推出首个黄金档嘉宾“夜聊”节目;阿华田中国首发两款新品;帝亚吉欧中国首家麦芽威士忌酒厂正式动工 | 食品饮料新品...
  3. 【产业互联网】源码资本眼中的产业互联网:连接赋能构建生态
  4. 数据仓库系列文章一:浅谈数仓设计
  5. Android 蓝牙系统打开蓝牙源码分析(一)--- 全网最详细
  6. 转自stormzhang的一些博文
  7. 从0开始学习 GitHub 系列之「03.Git 速成」----转载自stormzhang 原创文章
  8. mysql 统计表中条目数量的几种方法
  9. 项目计划表格甘特图_项目管理:什么是甘特图?
  10. mongodb用户权限管理配置