PIXI.js ColorMatrixFilter Type 'number[]' is not assignable to type '[number, ...number[]]'?

72 Views Asked by At

I wrote a function, it was always works fine

getLightMatrix(value: number): number[] {
    let m = [
        1,0,0,0,value,
        0,1,0,0,value,
        0,0,1,0,value,
        0,0,0,1,0,
    ];
    return m;
}
let m = new PIXI.filters.ColorMatrixFilter();
m.matrix = getLightMatrix(1);

Recently, when I used Pixi 6.2.0, will display error TS2322: Type 'number[]' is not assignable to type 'ColorMatrix'. Type 'number[]' is not assignable to type '[number, ...number[]]'. Source provides no match for required element at position 0 in target.

If I assign a number[] directly to it

let m = new PIXI.filters.ColorMatrixFilter();
m.matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];

Pass verification, How do I modify it?

0

There are 0 best solutions below