Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Move mouse - click to stamp current version to background
css
html, body, svg { width: 100vw; height: 100vh; margin: 0; padding: 0; } .copy { opacity: .6; } path { stroke: hsla(0,10%,60%,.75); } .info { text-align: center; width: 50%; height: 100px; position: fixed; top: 35%; z-index: 10; left: 25%; font-size: 24pt; font-family: monospace; color: hsla(0,0%,10%,0.5); transition: opacity 1.2s; pointer-events: none; user-select: none; } .moved .info {opacity: 0;}
JavaScript
Object.prototype.rad = (deg) => (Math.PI / 180) * deg; Object.prototype.deg = (rad) => (180 / Math.PI) * rad; Object.prototype.getAngle = (point1, point2) => Math.atan2(point1.y - point2.y, point1.x - point2.x); Object.prototype.getDistance = (point1, point2) => Math.sqrt(Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2)); const eleResult = document.querySelector(".result"); const elePath = document.querySelector("#fibo"); const eleSpiral = document.querySelector(".spiral"); const eleCopy = document.querySelector(".copy"); const NS = eleResult.namespaceURI; let ROTATE = 10; const fibo = [0, 1]; const pos = 1; let CX, CY; let maxValue = -1; let minValue = Infinity; let divide = 100; let ddeg = 10; let crossLines = []; function next() { fibo.push(fibo[fibo.length - 1] + fibo[fibo.length - 2]); return fibo[fibo.length - 1]; } for (var i = 0; i < 50; i++) { const current = next(); const x = fibo.length; } window.addEventListener("click", ({ clientX, clientY }) => { eleCopy.innerHTML += eleSpiral.innerHTML; }); window.addEventListener("dblclick", ({ clientX, clientY }) => { eleCopy.innerHTML = eleSpiral.innerHTML; }); window.addEventListener("mousemove", ({ clientX, clientY }) => { document.body.classList.add('moved'); CX = clientX; CY = clientY; eleSpiral.innerHTML = ""; crossLines = []; ROTATE = Math.cos(Math.rad(Date.now().toFixed()/200))*40+80; ROTATE = Math.abs(ROTATE) < 1 ? 1 : ROTATE; for (var i = 0; i < 360; i += ROTATE) { addSpiral(i + ddeg, divide, i); } for (var i = 0; i < fibo.length; i++) { const spiral = c( "path", { d:crossLines[i]+' Z', fill: "transparent", "stroke-width": "1px" }, NS ); eleSpiral.appendChild(spiral); } divide++; ddeg += 5; }); function addSpiral(ddeg = 0, divide, i) { let d = ""; for (var x = 0; x < fibo.length; x++) { let y = fibo[x]; let rad = Math.rad(x * ROTATE + ddeg); let xx = (Math.cos(rad) * y) / divide + CX; let yy = (Math.sin(rad) * y) / divide + CY; if (d === "") { d = `M ${xx} ${yy} L `; } d += `${xx} ${yy} `; if (crossLines[x] === undefined) { crossLines[x] = `M ${xx} ${yy} L `; } crossLines[x] += `${xx} ${yy} `; } const spiral = c( "path", { d, fill: "transparent", stroke: "black", "stroke-width": "1px" }, NS ); eleSpiral.appendChild(spiral); } function setMinMax(y) { maxValue = Math.min(innerHeight, Math.max(maxValue, y)); minValue = Math.min(minValue, y); //eleResult.setAttribute("viewBox", `0 0 ${fibo.length} ${maxValue}`); } function c(tagName, attributes, ns) { const ele = ns ? document.createElementNS(ns, tagName) : document.createElement(tagName); for (att in attributes) { ele.setAttribute(att, attributes[att]); } return ele; }
粒子
时间
文字
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号