Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body { background: #000; overflow: hidden; } canvas { width: 100%; height: 100%; position: absolute; left: 0; top: 0; }
JavaScript
var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}var Line = function () { function Line(x, y, size, color, speed, seed, amplitude) {_classCallCheck(this, Line); this.x = x; this.y = y; this.size = size; this.color = color; this.speed = speed; this.seed = seed; this.amplitude = amplitude; this.i = this.seed; }_createClass(Line, [{ key: 'update', value: function update() { this.y -= this.speed; this.i += this.seed; } }, { key: 'draw', value: function draw( canvas) { var x = this.x + Math.sin(this.i) * this.amplitude; canvas.ctx.beginPath(); canvas.ctx.fillStyle = this.color; canvas.ctx.shadowColor = this.color; canvas.ctx.shadowBlur = 5; canvas.ctx.arc(x, this.y, this.size, 0, 2 * Math.PI); canvas.ctx.fill(); canvas.ctx.closePath(); } }]);return Line;}();var Canvas = function () { function Canvas(ctx, w, h) {_classCallCheck(this, Canvas); this.ctx = ctx; this.width = w; this.height = h; this.scale = 1.0; this.lines = []; }_createClass(Canvas, [{ key: 'pushParticle', value: function pushParticle() { var x = Math.random() * this.width; var y = this.height + Math.random() * 250; var size = 1 + Math.random(); var g = Math.floor(150 + Math.random() * 50); var b = Math.floor(150 + Math.random() * 50); var color = 'rgba(120,' + g + ',' + b + ',0.7)'; var speed = 2 + Math.random() * 1.5; var seed = Math.random() / 20; var amp = Math.random() * 15; this.lines.push(new Line(x, y, size, color, speed, seed, amp)); } }, { key: 'start', value: function start() { for (var i = 0; i < 100; i++) { this.pushParticle(); } } }, { key: 'update', value: function update() { for (var i = 0; i < this.lines.length; i++) { var line = this.lines[i]; line.update(); } this.lines = this.lines.filter(function (line) { return line.y > -2; }); var toAdd = 100 - this.lines.length; if (toAdd === 0) {return;} for (var _i = 0; _i < toAdd; _i++) { this.pushParticle(); } } }, { key: 'draw', value: function draw() { this.ctx.shadowColor = '#000'; this.ctx.shadowBlur = 0; this.ctx.globalCompositeOperation = 'source-over'; this.ctx.fillStyle = 'rgba(0, 0, 0, 0.05)'; this.ctx.fillRect(0, 0, this.width, this.height); this.ctx.globalCompositeOperation = 'lighter'; for (var i = 0; i < this.lines.length; i++) { var line = this.lines[i]; line.draw(this); } } }]);return Canvas;}(); (function (_) { var canvasElement = document.getElementById('canvas'), ctx = canvasElement.getContext('2d'), canvas = new Canvas(ctx); var w = canvasElement.width = window.innerWidth, h = canvasElement.height = window.innerHeight, density = 1; function setup() { window.addEventListener('resize', resize); density = window.devicePixelRatio != undefined ? window.devicePixelRatio : 1.0; canvasElement.width = w * density; canvasElement.height = h * density; canvas.width = w; canvas.height = h; canvas.scale = density; ctx.scale(density, density); canvas.start(); draw(); } function draw() { canvas.update(); canvas.draw(); window.requestAnimationFrame(draw); } function resize() { w = canvasElement.width = window.innerWidth; h = canvasElement.height = window.innerHeight; canvasElement.width = w * density; canvasElement.height = h * density; canvas.width = w; canvas.height = h; ctx.scale(density, density); } setup(); })();
粒子
时间
文字
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号