在PIXI.js中如何增加精灵的亮度?

时间:2014-04-02 12:46:56

标签: pixi.js

我有一个通过new PIXI.Sprite.fromImage(path)创建的精灵,我怎样才能实时提高它的亮度?

1 个答案:

答案 0 :(得分:9)

您可以使用PIXI ColorMatrixFilter:

执行此操作
var colorMatrix =  [
    1,0,0,0,
    0,1,0,0,
    0,0,1,0,
    0,0,0,1
];
var filter = new PIXI.ColorMatrixFilter();
filter.matrix = colorMatrix;
stage.filters = [filter];

较暗:

var colorMatrix =  [
    1,0,0,-0.5,
    0,1,0,-0.5,
    0,0,1,-0.5,
    0,0,0,1
];

打火机:

var colorMatrix =  [
    1,0,0,0.5,
    0,1,0,0.5,
    0,0,1,0.5,
    0,0,0,1
];

请在此处查看快速演示:http://codepen.io/ianmcgregor/pen/LcjBw