网页动态蜘蛛网线条特效

花里胡哨50篇博客:https://blog.csdn.net/libusi001/article/details/100185337

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

一、页面引用

<script th:src="@{/js/canvas-nest.js}"></script>

二、js代码

/**
 * Despection 转自GitHub作者hustcc,特此说明!
 * Copyright (c) 2019 hustcc
 * Version: v1.0.1
 * GitHub: https://github.com/hustcc/canvas-nest.js
 **/
!function () {
    function n(n, e, t) {
        return n.getAttribute(e) || t
    }

    function e(n) {
        return document.getElementsByTagName(n)
    }

    function t() {
        var t = e("script"), o = t.length, i = t[o - 1];
        return {l: o, z: n(i, "zIndex", -1), o: n(i, "opacity", .5), c: n(i, "color", "0,0,0"), n: n(i, "count", 200)}
    }

    function o() {
        a = m.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, c = m.height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
    }

    function i() {
        r.clearRect(0, 0, a, c);
        var n, e, t, o, m, l;
        s.forEach(function (i, x) {
            for (i.x += i.xa, i.y += i.ya, i.xa *= i.x > a || i.x < 0 ? -1 : 1, i.ya *= i.y > c || i.y < 0 ? -1 : 1, r.fillRect(i.x - .5, i.y - .5, 1, 1), e = x + 1; e < u.length; e++) n = u[e], null !== n.x && null !== n.y && (o = i.x - n.x, m = i.y - n.y, l = o * o + m * m, l < n.max && (n === y && l >= n.max / 2 && (i.x -= .03 * o, i.y -= .03 * m), t = (n.max - l) / n.max, r.beginPath(), r.lineWidth = t / 2, r.strokeStyle = "rgba(" + d.c + "," + (t + .2) + ")", r.moveTo(i.x, i.y), r.lineTo(n.x, n.y), r.stroke()))
        }), x(i)
    }

    var a, c, u, m = document.createElement("canvas"), d = t(), l = "c_n" + d.l, r = m.getContext("2d"),
        x = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (n) {
            window.setTimeout(n, 1e3 / 45)
        }, w = Math.random, y = {x: null, y: null, max: 2e4};
    m.id = l, m.style.cssText = "position:fixed;top:0;left:0;z-index:" + d.z + ";opacity:" + d.o, e("body")[0].appendChild(m), o(), window.onresize = o, window.onmousemove = function (n) {
        n = n || window.event, y.x = n.clientX, y.y = n.clientY
    }, window.onmouseout = function () {
        y.x = null, y.y = null
    };
    for (var s = [], f = 0; d.n > f; f++) {
        var h = w() * a, g = w() * c, v = 2 * w() - 1, p = 2 * w() - 1;
        s.push({x: h, y: g, xa: v, ya: p, max: 6e3})
    }
    u = s.concat([y]), setTimeout(function () {
        i()
    }, 100)
}();

三、参数修改

1、线条密度参数:count

    function t() {
        var t = e("script"), o = t.length, i = t[o - 1];
        return {l: o, z: n(i, "zIndex", -1), o: n(i, "opacity", .5), c: n(i, "color", "0,0,0"), n: n(i, "count", 200)}
    }

2、其他

四、效果

有用请点赞,养成良好习惯!

疑问、交流、鼓励请留言!

 

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
QCustomPlot 是一个 C++ 图形绘图库,它提供了丰富的绘图功能,包括曲线图、散点图、柱状图、等值线图等。QCustomPlot 也支持绘制雷达图(蜘蛛网图)。 在 QCustomPlot 中,绘制雷达图需要使用 QCPGraph 类。该类提供了 setLineStyle、setScatterStyle、setData 等方法用于设置线型、散点和数据等属性。具体绘制步骤如下: 1. 创建一个 QCustomPlot 实例并设置其大小和背景色。 2. 创建一个 QCPGraph 实例并设置其线型、散点和数据等属性。 3. 创建一个 QCPAxisRect 实例并将其与 QCustomPlot 关联。 4. 创建一个 QCPAxis 实例并将其与 QCPAxisRect 关联,用于设置雷达图的轴线。 5. 使用 QCustomPlot 的 addPlottable 方法将 QCPGraph 添加到 QCustomPlot 中。 6. 最后,调用 QCustomPlot 的 replot 方法刷新绘图。 下面是一个简单的 QCustomPlot 绘制雷达图的示例代码: ```cpp // 创建 QCustomPlot 实例并设置其大小和背景色 QCustomPlot *customPlot = new QCustomPlot(this); customPlot->setGeometry(10, 10, 400, 400); customPlot->setBackground(QBrush(Qt::white)); // 创建 QCPGraph 实例并设置其线型、散点和数据等属性 QVector<double> data = {1, 3, 2, 4, 5}; QCPGraph *graph = new QCPGraph(customPlot->xAxis, customPlot->yAxis); graph->setLineStyle(QCPGraph::lsLine); graph->setScatterStyle(QCPScatterStyle::ssCircle); graph->setData(QVector<double>({0, 1, 2, 3, 4}), data); // 创建 QCPAxisRect 实例并将其与 QCustomPlot 关联 QCPAxisRect *axisRect = new QCPAxisRect(customPlot); customPlot->plotLayout()->addElement(0, 0, axisRect); // 创建 QCPAxis 实例并将其与 QCPAxisRect 关联 QCPAxis *axis = new QCPAxis(axisRect, QCPAxis::AxisType::atPolar); axis->setRange(0, 5); axis->setTickStep(1); axis->setSubTickCount(4); axis->grid()->setVisible(true); axisRect->addAxis(QCPAxis::atLeft, axis); // 将 QCPGraph 添加到 QCustomPlot 中 customPlot->addPlottable(graph); // 刷新绘图 customPlot->replot(); ``` 上述代码将绘制一个简单的雷达图,其中包含一个 QCPGraph 对象,使用折线和圆圈表示数据点,使用 QCPAxisRect 和 QCPAxis 对象设置雷达图的轴线。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

慕白Lee

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值