I have a sprite created through new PIXI.Sprite.fromImage(path)
, how can I increase the brightness of it in realtime?
You can do this using the 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];
Darker:
var colorMatrix = [
1,0,0,-0.5,
0,1,0,-0.5,
0,0,1,-0.5,
0,0,0,1
];
Lighter:
var colorMatrix = [
1,0,0,0.5,
0,1,0,0.5,
0,0,1,0.5,
0,0,0,1
];
See a quick demo here: http://codepen.io/ianmcgregor/pen/LcjBw
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With