Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Show Points
css
#svg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; } #path1 { fill: #2196F3; } #path2 { fill: #64b5f6; } .controls { position: fixed; top: 0; left: 0; padding: 15px; } .dot { fill: #1a237e; fill-opacity: 0.3; stroke: #1a237e; stroke-width: 1; vector-effect: non-scaling-stroke; }
JavaScript
var blob1 = createBlob({ element: document.querySelector("#path1"), numPoints: 20, centerX: 500, centerY: 500, minRadius: 300, maxRadius: 325, minDuration: 1, maxDuration: 2 }); var blob2 = createBlob({ element: document.querySelector("#path2"), numPoints: 10, centerX: 500, centerY: 500, minRadius: 200, maxRadius: 225, minDuration: 0.75, maxDuration: 1.75 }); // To show the points createDots([blob1, blob2]); function createBlob(options) { var points = []; var path = options.element; var slice = (Math.PI * 2) / options.numPoints; var startAngle = random(Math.PI * 2); var tl = new TimelineMax({ onUpdate: update }); for (var i = 0; i < options.numPoints; i++) { var angle = startAngle + i * slice; var duration = random(options.minDuration, options.maxDuration); var point = { x: options.centerX + Math.cos(angle) * options.minRadius, y: options.centerY + Math.sin(angle) * options.minRadius }; var tween = TweenMax.to(point, duration, { x: options.centerX + Math.cos(angle) * options.maxRadius, y: options.centerY + Math.sin(angle) * options.maxRadius, repeat: -1, yoyo: true, ease: Sine.easeInOut }); tl.add(tween, -random(duration)); points.push(point); } options.tl = tl; options.points = points; function update() { path.setAttribute("d", cardinal(points, true, 1)); } return options; } // Cardinal spline - a uniform Catmull-Rom spline with a tension option function cardinal(data, closed, tension) { if (data.length < 1) return "M0 0"; if (tension == null) tension = 1; var size = data.length - (closed ? 0 : 1); var path = "M" + data[0].x + " " + data[0].y + " C"; for (var i = 0; i < size; i++) { var p0, p1, p2, p3; if (closed) { p0 = data[(i - 1 + size) % size]; p1 = data[i]; p2 = data[(i + 1) % size]; p3 = data[(i + 2) % size]; } else { p0 = i == 0 ? data[0] : data[i - 1]; p1 = data[i]; p2 = data[i + 1]; p3 = i == size - 1 ? p2 : data[i + 2]; } var x1 = p1.x + (p2.x - p0.x) / 6 * tension; var y1 = p1.y + (p2.y - p0.y) / 6 * tension; var x2 = p2.x - (p3.x - p1.x) / 6 * tension; var y2 = p2.y - (p3.y - p1.y) / 6 * tension; path += " " + x1 + " " + y1 + " " + x2 + " " + y2 + " " + p2.x + " " + p2.y; } return closed ? path + "z" : path; } function random(min, max) { if (max == null) { max = min; min = 0; } if (min > max) { var tmp = min; min = max; max = tmp; } return min + (max - min) * Math.random(); } function createDots(blobs) { var dotContainer = document.querySelector("#dot-container"); var checkBox = document.querySelector("#show-points"); var showPoints = true; var points = []; var dots = []; blobs.forEach(function(blob) { blob.points.forEach(function(point) { var dot = document.createElementNS("http://www.w3.org/2000/svg", "circle"); dot.setAttribute("r", 4); dot.setAttribute("class", "dot"); dotContainer.appendChild(dot); dots.push(dot); points.push(point); }); }); onChange(); checkBox.addEventListener("change", onChange); TweenLite.ticker.addEventListener("tick", update); function onChange() { showPoints = checkBox.checked; dotContainer.style.setProperty("visibility", showPoints ? "visible" : "hidden"); } function update() { if (!showPoints) { return; } for (var i = 0; i < points.length; i++) { var p = points[i]; dots[i].setAttribute("transform", "translate(" + p.x + "," + p.y + ")"); } } }
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>SVG Blob-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号