Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Canvas not supported.
Scroll right to speed up.
css
* { margin: 0; padding: 0; } canvas#canvas { display: block; background: #092745; } ul#navigation { display: none; } @media screen and (min-width: 48rem) { ul#navigation { position: absolute; height: 100%; top: 0; right: 0; -webkit-writing-mode: vertical-rl; -ms-writing-mode: tb-rl; writing-mode: vertical-rl; text-align: center; margin-right: 1.6rem; font-size: 0.8rem; } ul#navigation > li { display: inline-block; } }
JavaScript
(function () { 'use strict'; window.addEventListener('load', function () { var canvas = document.getElementById('canvas'); if (!canvas || !canvas.getContext) { return false; } /******************** Random Number ********************/ function rand(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } /******************** Var ********************/ var ctx = canvas.getContext('2d'); var X = canvas.width = window.innerWidth; var Y = canvas.height = window.innerHeight; var mouseX = X / 2; var mouseY = Y / 2; var ellipses = []; var ellipseNum = X / 10 + 1; /******************** Animation ********************/ window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function(cb) { setTimeout(cb, 17); }; /******************** Ellipse ********************/ function Ellipse(ctx, x, y, i) { this.ctx = ctx; this.init(x, y, i); } Ellipse.prototype.init = function(x, y, i) { this.x = x; this.y = y; this.i = i; this.r = Y / 40; this.v = { x: 0, y: 0 }; this.c = { r: rand(0, 255), g: rand(0, 255), b: rand(200, 255), a: 1 }; this.a = i * 2; this.rad = this.a * Math.PI / 180; }; Ellipse.prototype.draw = function() { var ctx = this.ctx; ctx.save(); ctx.globalCompositeOperation = 'lighter'; ctx.beginPath(); ctx.translate(this.x, this.y); ctx.scale(1.2, 20); ctx.fillStyle = this.gradient(); ctx.translate(-this.x, -this.y); ctx.arc(Math.cos(this.rad) * 20 + this.x, Math.sin(this.rad) * 1 + this.y, this.r, 0, Math.PI * 2, false); ctx.fill(); ctx.restore(); }; Ellipse.prototype.gradient = function () { var col = this.c.r + "," + this.c.g + "," + this.c.b; var g = this.ctx.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.r); g.addColorStop(0, "rgba(" + col + ", " + (this.c.a * 1) + ")"); g.addColorStop(0.5, "rgba(" + col + ", " + (this.c.a * 0.7) + ")"); g.addColorStop(1, "rgba(" + col + ", " + (this.c.a * 0) + ")"); return g; }; Ellipse.prototype.updateParams = function() { this.a += 0.7; this.rad = this.a * Math.PI / 180; }; Ellipse.prototype.render = function() { this.updateParams(); this.draw(); }; for (var i = 0; i < ellipseNum; i++) { var e = new Ellipse(ctx, 0 + i * 10, Y / 2, i); ellipses.push(e); } /******************** Render ********************/ function render() { ctx.clearRect(0, 0, X, Y); for (var i = 0; i < ellipses.length; i++) { ellipses[i].render(); } requestAnimationFrame(render); } render(); /******************** Event ********************/ function onResize() { X = canvas.width = window.innerWidth; Y = canvas.height = window.innerHeight; ellipses = []; ellipseNum = X / 10 + 1; for (var i = 0; i < ellipseNum; i++) { var e = new Ellipse(ctx, 0 + i * 10, Y / 2, i); ellipses.push(e); } } window.addEventListener('resize', function(){ onResize(); }); canvas.addEventListener('mousemove', function(e) { mouseX = e.clientX; mouseY = e.clientY; for (var i = 0; i < ellipses.length; i++) { ellipses[i].y += rand(-5, 5); } }); canvas.addEventListener('touchmove', function(e) { var touch = event.targetTouches[0]; mouseX = touch.pageX; mouseY = touch.pageY; for (var i = 0; i < ellipses.length; i++) { ellipses[i].y += rand(-5, 5); } }, false); canvas.addEventListener('wheel', function(e) { for (var i = 0; i < ellipses.length; i++) { ellipses[i].a += e.deltaX; } }); }); // Author console.log('File Name / illumina.js\nCreated Date / May 27, 2020\nAuthor / Toshiya Marukubo\nTwitter / https://twitter.com/toshiyamarukubo'); })();
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title> 纯JavaScript光影-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号