导航

萌即是正义!时不时分享一些ACG活动记录与有趣代码的小站!

侧边栏
热门文章
1推文
被 ChatGPT images 2.0 的效果惊艳到了。
热度
827
2页面
程序员老黄历&求签
热度
624
3推文
试用了 GitHub Copilot 的 Opus 4.7,整体体验并不理想。 我拿一个从零开始的工具类项目做测试,前后尝试了 5 次,竟然有 3 次直接被拒绝。理由都是认为这个项目需要团队投入数周甚至数月,超出了 AI 能完成的范围。但实际上,这个项目代码量最多也就一万行左右,我一个人一个周末完全可以完成。 这种“直接拒绝”的处理方式确实有些过头,系统级提示词到底是如何设计的?类似情况在 4.6 版本中从未出现过。当初难度更高的项目(比如维基萌公会)都能被耐心完成。 在我不断调整提示词、强烈要求之后,有 2 次成功执行,但结果质量依然不尽如人意,问题包括但不限于: 功能缺失、逻辑遗漏 声称“已完成”,但实际并未完成 无视我提供的前端代码,自行重新实现 在一个表单中,将多个字段通过遍历逐个提交的低效做法 这些问题,本质上更像是思考深度不足导致的。相比之下,Github Copilot 版的 4.6 思考深度是高,而 4.7 是中。 总体来说,4.7 在价格提升数倍的情况下,却带来了明显下降的体验,难免让人失望。更何况还强制下架了 4.6,以“升级”为名降低成本,这种做法确实难以令人认同。
热度
181
4博文
3DS模拟器简体中文字库 | Citra3ds字库 | 符文工房4乱码解决字库 | shared_font.bin
热度
104
5博文
面码找到你了!探寻超平和Busters的秘密基地——《我们仍未知道那天所看见的花的名字》秩父圣地巡礼
热度
91
6推文
Github Copilot 停止了新用户注册,并且下架了opus4.6,还增加了用户的每周使用限制。 看来面向个人用户的AI好时代提前结束了?
热度
52
7推文
Github的Copilot最近突然对付费用户增加了使用限额,但是没有公布限额总量的具体数值,只能查看一个百分比。不同模型的使用倍率也有所不同。 试了一下代理模式将1000行的代码中的中文提取出来做成语言包并翻译成英文就花费了1.7%的请求。 感觉这样的限制对于我这样的重度用户影响挺大的。
热度
52
8博文
那些评测软文不会告诉你的 文石BOOX Leaf3C 细节体验报告
热度
52
9博文
《女神异闻录5》圣地巡礼——三轩茶屋
热度
52
10推文
我进入了迷途橘。
热度
39
最新评论
MaDao
2026-04-24 19:35
OωO
石樱灯笼
2026-04-24 14:30
@广树:是越来越像人了
广树管理员
2026-04-23 19:15
@saber酱:代码补全以前免费用户有额度的。现在没有免费用户就没了。但是聊天我一直记得是消耗的。
saber酱
2026-04-23 19:13
@广树:就是和终端并列的聊天窗口,那也许是我记错了。之前 Copilot 的使用量面板里,代码补全和聊天消息都是不会显示百分比的,只有一个横条。现在这俩都没了,只有高级请求的百分比了
广树管理员
2026-04-23 19:10
@saber酱:聊天是哪里的聊天?我印象里是一直都算的呀?比如在我的vscode里
攻略中
告别回忆 双想 ~Not always true~
暂无评分
Steam告别回忆 双想 ~Not always true~
2026年3月10日 22时 ~ 攻略中
已累计游玩1个月15天
“我觅见了生命中的唯一,而后——”
亚路塔:狐狸狐途的面包冒险
暂无评分
Steam亚路塔:狐狸狐途的面包冒险
2026年2月12日 19时 ~ 攻略中
已累计游玩2个月11天
一场席卷全世界的面包革命现在开始! 主人公查雅阴错阳差之下,开始了在荒废的岛屿上经营面包店的生活。 出外冒险搜集食材、研发崭新面包配方、遇见性格各异的伙伴们,建造更丰富的设施,用面包香气使无人问津的广场再次热闹起来!
ToHeart
暂无评分
SteamToHeart
2025年6月26日 19时 ~ 攻略中
已累计游玩10个月2天
AQUAPLUS推出的“温暖人心的校园恋爱游戏”将以高清全3D形式焕新归来!
fault - StP - LIGHTKRAVTE
暂无评分
Steamfault - StP - LIGHTKRAVTE
2025年5月29日 20时 ~ 攻略中
已累计游玩11个月
全球累计销量超过50万份的“fault”系列最新作!故事的舞台是一个融合了奇幻与科幻的超前世界——卢森海德王国。本作讲述了生活在此地的一个平凡又平庸的究极普通市民——名为果子的少年的故事。
PSN奖杯卡

PSN奖杯卡

归档
赞助商广告

用canvas做 精灵 | 光点 | 粒子 | 光子 飘动的效果

作者:广树时间:2018-03-08 17:01:04分类:JavaScript

前面做《四女神Online》模板的时候参照code pen上的一则飘雪效果改的。

首先引入HTML并想好canvas的ID:

<canvas id='canvasbg' class="star_effect"></canvas>

然后引入JS:

(function() {

    var Base, Particle, canvas, colors, context, drawables, i, mouseX, mouseY, mouseVX, mouseVY, rand, click, min, max, colors, particles, Cwidth, Cheight, GradientColors, CanvasEl;

    CanvasEl = "canvasbg"; //Canvas的ID
    min = 1; //最小光点直径
    max = 4; //最大光点直径
    particles = 200; //光点数量
    Cwidth = 800; //画布宽度
    Cheight = 600; //画布高度
    colors = ["255, 255, 255", "250, 150, 20", "255, 100, 255"]; //光点中间的颜色注意和晕开颜色顺序配对
    GradientColors = ["84,204,243", "250,150,20", "255, 100, 255"]; //光点晕开的颜色色注意和中间颜色顺序配对
    rand = function(a, b) {
        return Math.random() * (b - a) + a;
    };

    Particle = (function() {
        function Particle() {
            this.reset();
        }

        Particle.prototype.reset = function() {
            var colorSel = Math.random();
            this.color = colors[~~ (colorSel * colors.length)];
            this.GradientColors = GradientColors[~~ (colorSel * GradientColors.length)];
            this.radius = rand(min, max);
            this.x = rand(0, canvas.width);
            this.y = rand(60, canvas.height);
            this.vx = -5 + Math.random() * 10;
            this.vy = (Math.random() - 0.5) * this.radius;
            this.valpha = rand(0.02, 0.09);
            this.opacity = 0;
            this.life = 0;
            this.onupdate = undefined;
            this.type = "dust";
        };

        Particle.prototype.update = function() {
            this.x = (this.x + this.vx / 6);
            this.y = (this.y + this.vy / 6);

            if (this.opacity >= 1 && this.valpha > 0) this.valpha *= -1;
            this.opacity += this.valpha / 8;
            this.life += this.valpha / 8;

            if (this.type === "dust") this.opacity = Math.min(1, Math.max(0, this.opacity));
            else this.opacity = 1;

            if (this.onupdate) this.onupdate();
            if (this.life < 0 || this.radius <= 0 || this.y > canvas.height) {
                this.onupdate = undefined;
                this.reset();
            }
        };

        Particle.prototype.draw = function(c) {
            var grd = c.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.radius * 4);
            grd.addColorStop(0, "rgba(" + this.GradientColors + ", " + Math.min(this.opacity - 0.2, 0.65) + ")");
            grd.addColorStop(1, "rgba(" + this.GradientColors + ", " + '0' + ")");
            c.fillStyle = grd;

            c.beginPath();
            c.arc(this.x, this.y, this.radius * 4, 2 * Math.PI, false);
            c.fill();

            c.strokeStyle = "rgba(" + this.color + ", " + Math.min(this.opacity, 0.85) + ")";
            c.fillStyle = "rgba(" + this.color + ", " + Math.min(this.opacity, 0.65) + ")";
            c.beginPath();
            c.arc(this.x, this.y, this.radius, 2 * Math.PI, false);
            c.fill();
        };

        return Particle;

    })();

    mouseVX = mouseVY = mouseX = mouseY = 0;

    canvas = document.getElementById(CanvasEl);
    context = canvas.getContext("2d");
    canvas.width = Cwidth;
    canvas.height = Cheight;

    drawables = (function() {
        var _i, _results;
        _results = [];
        for (i = _i = 1; _i <= particles; i = ++_i) {
            _results.push(new Particle);
        }
        return _results;
    })();

    function draw() {
        window.requestAnimFrame(draw);
        var d, _i, _len;
        canvas.width = Cwidth;
        canvas.height = Cheight;
        context.clearRect(0, 0, canvas.width, canvas.height)

        for (_i = 0, _len = drawables.length; _i < _len; _i++) {
            d = drawables[_i];
            d.draw(context);
        }
    };

    function update() {
        window.requestAnimFrame(update);
        var d, _i, _len, _results;
        _results = [];
        for (_i = 0, _len = drawables.length; _i < _len; _i++) {
            d = drawables[_i];
            _results.push(d.update());
        }
        return _results;
    };

    document.onmousemove = function(e) {
        mouseVX = mouseX;
        mouseVY = mouseY;
        mouseX = ~~e.pageX;
        mouseY = ~~e.pageY;
        mouseVX = ~~ ((mouseVX - mouseX) / 2);
        mouseVY = ~~ ((mouseVY - mouseY) / 2);

    };

    window.addEventListener('resize', draw, false);
    window.requestAnimFrame = (function() {
        return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||
        function(callback) {
            window.setTimeout(callback, 1000 / 60);
        };
    })();
    window.requestAnimFrame(draw);
    window.requestAnimFrame(update);
}).call(this);


可设置的参数有:
CanvasEl = "canvasbg";//Canvas的ID
min = 1;//最小光点直径
max = 4;//最大光点直径
particles = 200;//光点数量
Cwidth = 800;//画布宽度
Cheight = 600;//画布高度
colors = ["255, 255, 255","250, 150, 20","255, 100, 255"];//光点中间的颜色注意和晕开颜色顺序配对
GradientColors = ["84,204,243","250,150,20","255, 100, 255"];//光点晕开的颜色色注意和中间颜色顺序配对
注意:光点和光晕的顺序是配对的,比如第一个光点会搭配第一个光晕。






donate.png


telegram banner (1).png