Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
* { border: 0; box-sizing: border-box; margin: 0; padding: 0; } body { background-color: #000; color: #e3e4e8; display: flex; height: 100vh; } canvas { display: block; margin: auto; object-fit: contain; max-width: 100vw; max-height: 100vh; }
JavaScript
document.addEventListener("DOMContentLoaded",app); function app() { let C = document.querySelector("canvas"), c = C.getContext("2d"), W = 600, H = 600, centerX = W / 2, centerY = H / 2, S = window.devicePixelRatio; // properly scale the canvas based on pixel ratio C.width = W * S; C.height = H * S; if (S > 1) { C.style.width = `${W}px`; C.style.height = `${H}px`; c.scale(S,S); } let frame = 0, frames = 360, speed = 1.5, hue = 0, baseRingRadius = 64, baseRingsInGroup = 6, ringGroups = 8, ringGroupRadiusOffset = 14, ringGroupRotOffset = 30, degToRad = deg => { return deg * Math.PI / 180; }, draw = () => { c.clearRect(0,0,W,H); for (let g = 1; g <= ringGroups; ++g) { // determine the radius of the ring group let sectors = baseRingsInGroup * 2**(g - 1), ringRadius = baseRingRadius / g, groupRadius = baseRingRadius; for (let m = 1; m < g; ++m) groupRadius += baseRingRadius / m; // ring texture let adjGroupRadius = ringGroupRadiusOffset + groupRadius, texture = c.createLinearGradient(0,-ringRadius,0,ringRadius); texture.addColorStop(0,`hsl(${hue},90%,75%)`); texture.addColorStop(0.33,`hsl(${hue},90%,55%)`); texture.addColorStop(1,`hsla(${hue},90%,55%,0)`); c.strokeStyle = texture; // draw each ring for (let s = 0; s < sectors; ++s) { let sectorAngle = 360 / sectors, rotAmount = ringGroupRotOffset + sectorAngle * s, sectorX = centerX + adjGroupRadius * Math.sin(degToRad(rotAmount)), sectorY = centerY + adjGroupRadius * Math.cos(degToRad(rotAmount)); c.save(); c.translate(sectorX,sectorY); c.rotate(degToRad(-rotAmount + frame)); c.beginPath(); c.arc(0,0,ringRadius,Math.PI * 0.5,Math.PI * 1.5); c.stroke(); c.closePath(); c.restore(); } } nextFrame(); }, nextFrame = () => { frame += speed; hue = frame; if (frame >= frames) frame = 0; }, run = () => { draw(); requestAnimationFrame(run); }; run(); }
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>canvas霓虹花幻象-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号