Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body, html { width: 100%; height: 100%; padding: 0; margin: 0; background: #000; overflow: hidden; } canvas { position: absolute; width: 100%; height: 100%; top: 0; left: 0; } h1 { position: relative; color: #464678; text-align: center; line-height: 8rem; font-size: 2rem; z-index: 100; } .aim { position: fixed; width: 100%; height: 100%; top: 0; left: 0; background: transparent; z-index: 50; -webkit-transform: translate3d(0, 0, 0); } .aim .c { position: absolute; top: 0; left: 0; width: 11px; height: 11px; background: #000; margin: -5px 0 0 -5px; -webkit-transform: rotate(45deg); transform: rotate(45deg); border: 1px solid #77f; } .aim .h { position: absolute; top: 1px; left: -50%; width: 200%; height: 1px; background: #77f; opacity: 0.5; } .aim .v { position: absolute; top: -50%; left: 1px; width: 1px; height: 200%; background: #77f; opacity: 0.5; }
JavaScript
"use strict"; var OPT = { selector: "#sparks", amount: 10000, speed: 0.1, // pixels per frame lifetime: 500, direction: { x: -0.5, y: 1 }, size: [1, 1], maxopacity: 1, color: "150, 150, 150", randColor: true, acceleration: [5, 40] }; if (window.innerWidth < 520) { OPT.speed = 0.05; OPT.color = "150, 150, 150"; } (function spark() { var canvas = document.querySelector(OPT.selector); var ctx = canvas.getContext("2d"); var sparks = []; window.addEventListener('resize', function () { setCanvasWidth(); }); function setCanvasWidth() { ctx.canvas.width = window.innerWidth; ctx.canvas.height = window.innerHeight; } function rand(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } // Init animation function init() { setCanvasWidth(); window.setInterval(function () { if (sparks.length < OPT.amount) { addSpark(); } }, 1000 / OPT.amount); window.requestAnimationFrame(draw); } function draw() { ctx.fillStyle = 'rgba(0,0,0, 0.1)'; ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height); sparks.forEach(function (spark, i, array) { if (spark.opacity <= 0) { array.splice(i, 1); } else { drawSpark(spark); } }); window.requestAnimationFrame(draw); } function Spark(x, y) { this.x = x; this.y = y; this.age = 0; this.acceleration = rand(OPT.acceleration[0], OPT.acceleration[1]); this.color = OPT.randColor ? rand(0, 255) + "," + rand(0, 255) + "," + rand(0, 255) : OPT.color; this.opacity = OPT.maxopacity - this.age / (OPT.lifetime * rand(1, 10)); this.go = function () { this.x += OPT.speed * OPT.direction.x * this.acceleration / 2; this.y += OPT.speed * OPT.direction.y * this.acceleration / 2; this.opacity = OPT.maxopacity - ++this.age / OPT.lifetime; }; } function addSpark() { var x = rand(-200, window.innerWidth + 200); var y = rand(-200, window.innerHeight + 200); sparks.push(new Spark(x, y)); } function drawSpark(spark) { var x = spark.x, y = spark.y; spark.go(); ctx.beginPath(); ctx.fillStyle = "rgba(" + spark.color + ", " + spark.opacity + ")"; ctx.rect(x, y, OPT.size[0], OPT.size[1], 0, 0, Math.PI * 2); ctx.fill(); } init(); })();
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>粒子雨-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号