Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
canvas { background: black; display: block; position:absolute; margin: auto; top:0;bottom:0;left:0;right:0 } body{background:#111; overflow:hidden; }
JavaScript
let rid = null; const ctx = cvs.getContext("2d"); let size = Math.min(window.innerWidth, window.innerHeight); const N = 6; let cw = (cvs.width = size); let ch = (cvs.height = size); let R = size / N; let A = 0; let cells = []; class Cell { constructor(x, y, n, d) { this.R = R / 2; this.r = this.R * 0.8; this.x = x; this.y = y; this.n = n; this.d = d; if (d > 0 && n > 0) { this.k = this.n / this.d; } this.cx = this.x + this.R; this.cy = this.y + this.R; this.points = []; } draw(_x, _y, A) { let a = this.d * A; ctx.save(); ctx.translate(this.cx, this.cy); ctx.rotate(-Math.PI / 2); //draw the curve if (this.k) { ctx.lineWidth = 1; ctx.beginPath(); for (let _a = 0; _a < this.d * 2 * Math.PI; _a += 0.01) { let x = this.r * Math.cos(_a * this.k) * Math.cos(_a); let y = this.r * Math.cos(_a * this.k) * Math.sin(_a); ctx.lineTo(x, y); } ctx.closePath(); ctx.strokeStyle = "#444"; ctx.stroke(); //-------------- ctx.beginPath(); ctx.moveTo(this.points.x, this.points.y); this.points.map((p) => { ctx.lineTo(p.x, p.y); }); ctx.strokeStyle = "aliceblue"; ctx.stroke(); } //draw the rod let x1 = this.r * Math.cos(a); let y1 = this.r * Math.sin(a); let x2 = this.r * Math.cos(a + Math.PI); let y2 = this.r * Math.sin(a + Math.PI); ctx.beginPath(); ctx.moveTo(x1, y1); ctx.lineTo(x2, y2); ctx.lineWidth = size / 100; ctx.lineCap = "round"; ctx.strokeStyle = grd(x1, y1, x2, y2); ctx.stroke(); //draw the thumb if (this.k) { drawthumb(_x, _y); } else { if (this.n == 0) { drawthumb(x1, y1); } else { drawthumb(this.r * Math.cos(this.n * A), 0); } } ctx.restore(); } update(A) { let a = this.d * A; let _x = this.r * Math.cos(a * this.k) * Math.cos(a); let _y = this.r * Math.cos(a * this.k) * Math.sin(a); //build the array of points if (a < this.d * 2 * Math.PI) { this.points.push({ x: _x, y: _y }); } else { this.points = []; } this.draw(_x, _y, A); } } function Draw() { rid = window.requestAnimationFrame(Draw); ctx.clearRect(0, 0, cw, ch); A <= 2 * Math.PI ? (A += 0.01) : (A = 0); cells.map((c) => { c.update(A); }); } function drawthumb(x, y) { ctx.beginPath(); ctx.arc(x, y, size / 100, 0, 2 * Math.PI); ctx.strokeStyle = "black"; ctx.fillStyle = "aliceblue"; ctx.lineWidth = 1; ctx.fill(); ctx.stroke(); } function grd(x1, y1, x2, y2) { let g = ctx.createLinearGradient(x1, y1, x2, y2); g.addColorStop(0.3, "#ab5a21"); g.addColorStop(0.5, "#fff"); g.addColorStop(0.7, "#ab5a21"); return g; } function Init() { if (rid) { window.cancelAnimationFrame(rid); rid = null; } size = Math.min(window.innerWidth, window.innerHeight); cw = cvs.width = size; ch = cvs.height = size; R = size / N; cells = []; let n = 0; for (let y = 0; y < size; y += R) { let d = 0; for (let x = 0; x < size; x += R) { cells.push(new Cell(x, y, d, n)); d++; } n++; } Draw(); } window.setTimeout(function () { Init(); window.addEventListener("resize", Init, false); }, 15);
粒子
时间
文字
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号