跳动爱心源码_附下载链接

简介: 跳动爱心源码_附下载链接

5e70d401b17a46159563f25e7c4050d4.jpgf55972fcadfc4d93ba79ea6ad4eeb700.jpg

<html>
<head>
    <meta charset="utf-8">
    <title>loveHeart</title>
    <style>
        html,
        body {
            height: 100%;
            padding: 0;
            margin: 0;
            background: #000;
        }
        canvas {
            position: absolute;
            width: 100%;
            height: 100%;
        }
        p{
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
            color: pink;
            animation: k 1.5s ease-in-out infinite;
        }
        @keyframes k{
            100%{
                font-size: 24px;
                opacity: 0;
            }
        }
    </style>
</head>
<body>
    <p></p>
    <canvas id="pinkboard"></canvas>
    <script>
        var settings = {
            particles: {
                length: 600,  // 爱心的大小
                duration: 2,  // 爱心扩散速度,越小速度越快
                velocity: 100,  // 爱心扩散速度,越小速度越慢
                effect: -0.75, // 爱心收缩效果,比如:1扩散,-2收缩
                size: 32, // 爱心数量
            },
        };
        (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) } } }());
        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;
        })();
        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;
        })();
        var ParticlePool = (function () {
            var particles,
                firstActive = 0,
                firstFree = 0,
                duration = settings.particles.duration;
            function ParticlePool(length) {
                // create and populate particle pool
                particles = 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 queue
                firstFree++;
                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 particles
                if (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 particles
                while (particles[firstActive].age >= duration && firstActive != firstFree) {
                    firstActive++;
                    if (firstActive == particles.length) firstActive = 0;
                }
            };
            ParticlePool.prototype.draw = function (context, image) {
                // draw active particles
                if (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;
        })();
        (function (canvas) {
            var context = canvas.getContext('2d'),
                particles = new ParticlePool(settings.particles.length),
                particleRate = settings.particles.length / settings.particles.duration, // particles/sec
                time;
            // get point on heart with -PI <= t <= PI
            function 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 canvas
            var 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 path
                function 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 path
                context.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 fill
                context.fillStyle = '#ea80b0';
                context.fill();
                // create the image
                var image = new Image();
                image.src = canvas.toDataURL();
                return image;
            })();
            // render that thing!
            function render() {
                // next animation frame
                requestAnimationFrame(render);
                // update time
                var newTime = new Date().getTime() / 1000,
                    deltaTime = newTime - (time || newTime);
                time = newTime;
                // clear canvas
                context.clearRect(0, 0, canvas.width, canvas.height);
                // create new particles
                var 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 particles
                particles.update(deltaTime);
                particles.draw(context, image);
            }
            // handle (re-)sizing of the canvas
            function onResize() {
                canvas.width = canvas.clientWidth;
                canvas.height = canvas.clientHeight;                                                                           
            }
            window.onresize = onResize;
            // delay rendering bootstrap
            setTimeout(function () {
                onResize();
                render();
            }, 10);
        })(document.getElementById('pinkboard'));
        </script>
</body>
</html>

不拖拉_直接用以下链接下载即可

跳动爱心源码_下载链接:

https://wwz.lanzoul.com/im90Y0fjt1pa

密码:6otr

有用的话点个赞~

相关文章
|
数据采集 JSON 编解码
收藏|Unsplash高清壁纸批量下载(源码+工具)!
收藏|Unsplash高清壁纸批量下载(源码+工具)!
|
存储 异构计算 Windows
ps2023汉化版百度网盘下载photoshop2023自带神经滤镜安装包
最近,ps迎来了2023的版本,这次的版本提升针对windows11做了特别优化,启动速度比win10快了很多。期盼已久的Win版 PS 2023 终于来了,小编也是通过特殊渠道搞来的,本期带来的WIN版本支持一键安装激活,一次安装永久免费使用 众所周知,版本越高,需要的电脑配置也就越来越高。下面放一下2023版本的配置供大家参考。需要注意的是这些版本不再支持windows7系统,仅支持win10及以上的操作系统。
10088 3
|
6月前
|
前端开发
前端实现视频或者图片直链下载
前端实现视频或者图片直链下载
240 0
|
6月前
分享一下基于autojs4的片多多源码
分享一下基于autojs4的片多多源码
76 1
|
监控 Serverless 持续交付
我们把“高血压”小游戏真正做到了不用下载,点击即玩!!!
我们把“高血压”小游戏真正做到了不用下载,点击即玩!!!
|
JSON API 数据格式
mxget 的Python实现,优雅地下载你喜欢的音乐
mxget 的Python实现,优雅地下载你喜欢的音乐
Photoshop2023无时间限制安装包下载
Photoshop简称“PS”,是一款常用和功能强大的图像处理软件。主要处理以像素所构成的数字图像。使用其众多的编修与绘图工具,可以有效地进行图片编辑工作。PS有很多功能,在图像、图形、文字、视频、出版等各方面都有涉及。
293 5
|
数据安全/隐私保护
FLStudio水果2023升级21完整版安装包下载
2022年12月7日晚,全球知名的音乐创作软件,FL Studio正式推出最新21版,为原创音乐人提供更好用的DAW(数字音乐工作站)工具。FLStudio水果下载如下:http://t.csdn.cn/8tvqc
248 0
|
Android开发 iOS开发 MacOS
ps2023最新版绿色资源下载安装包Photoshop23
大家好,我是为你们整理资源的小编。为什么会有这么多同学想要学PS?因为PS现在几乎是一个必备技能。现在是一个多元化的社会,并不是做设计工作才需要学PS,即使是日常办公,也需要懂一点PS。毕业的时候,如果你是老板,是倾向于招一个只会单一技能的员工,还是会多元化技能的员工?或者说,都2023年了?网络学习资源这么多,你居然还不会PS? PS算是技能类中门槛比较低的软件了,只要你用心学,简简单单入门没有问题。所以应同学们的强烈要求,我们这次对PS教程做了一次更新。
393 0
|
人工智能 数据可视化 Android开发
FL21水果软件2023全新完整版安装包下载FLStudio21
FLStudio21最新中文版是一款非常专业的后期编曲音频处理软件,对于音乐编辑处理的领域内的人而言,是非常能够满足需求的一款工具。FL Studio21拥有强大且专业的创作工具,这是先进的创作工具,让你的音乐突破想象力的限制。FL Studio 21创作属于自己风格的音乐、舞曲、轻音乐、流行歌曲,非常好用!FL下载21版本如下:http://t.csdn.cn/sq4Vl
673 0