导航

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

侧边栏
热门文章
1推文
开源节流,站点用来通知的邮箱地址从域名邮箱换成谷歌邮箱,国内邮箱接收的话有可能会进垃圾邮件。
热度
1014
2页面
程序员老黄历&求签
热度
455
3推文
历时1周1天,用时8小时,看完了《everlasting flowers》。 因为这次读的比较仔细,用了8个多小时看完,估计正常的流程应该是6-7小时之间。 那么,简单评价一下这款视觉小说吧。 先说优点,音乐很厉害,真的很厉害!越来越期待2月1日的钢琴音乐会了! FILMIC NOVEL概念的视觉小说在表现力方面确实强,是我目前看过的所有视觉小说中视觉冲击力最强的一款! 然后就是剧情方面了,对比前面两项优点确实逊色了一些,但是还是一个非常令人感动的一个故事。 剧情的前期、前中期、后期的剧情处理还不错,个人比较喜欢。 剧情前半段设置了一些伏笔,虽然一开始就发现了,但还蛮有趣的。 可能还是受到了篇幅限制,剧情的中期、中后期处理有一些差强人意,这导致了感情上的发展略显唐突了一些。 中后期剧情的冲突方面的描写也有一些弱,感觉没有处理好。 奖杯/成就方面差评,没有新内容的情况下强制看两遍,强制10小时的游戏时间...感觉还不如像《苍之彼方的四重奏》那样干脆就不设置白金奖杯。 不过总的来说在视觉小说领域还是属于上乘的佳作!推荐!
热度
286
4推文
芳文社的展览门票到了。 这次展览分了很多种门票和特典,这次选择的是《点兔》保登心爱在C位的门票,以及《点兔》杂志封面钥匙扣的特典。
热度
182
5博文
探索东京湾上的无人岛——猿岛游记
热度
143
6页面
游戏
热度
91
7页面
关于
热度
91
8页面
友链
热度
91
9页面
追番
热度
78
10博文
RPG Maker MV 插件制作入门(1)
热度
78
最新评论
广树
2024-09-20 12:18
@ZeroCounter:这个成就明显就是想你读两遍
ZeroCounter
2024-09-20 09:25
@广树:Visual Novel Data Base(https://vndb.org/),一个基于英文社群视觉小说数据库,里面有各种语言的玩家分享的通关时长和评价。区别于日本的那个批评空间,这个数据库对作品的收容范围比较广,基本上跟文字沾点边的都收录了(包括逆转裁判什么的)。 我不是说这部作品啦,人本来阅读速度就有快有慢,更不用说不同语言的阅读速度也有差异,全部按一个成就定标准有点太奇怪了(
广树
2024-09-20 08:49
@ZeroCounter:VNDB是什么?这么好的作品,一扫而光是不是有点太急了?本来生活节奏就这么快了,不应该慢下来享受阅读吗?何况音乐也那么好听。
广树
2024-09-20 08:48
@石樱灯笼:是的,对于我来说无所谓了
广树
2024-09-20 08:47
@圣眼大鹅:应该在群里艾特
正在攻略

image-0lhdm7m0.png


PSN奖杯卡

PSN奖杯卡

赞助商广告

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

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

前面做《四女神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"];//光点晕开的颜色色注意和中间颜色顺序配对
注意:光点和光晕的顺序是配对的,比如第一个光点会搭配第一个光晕。