为啥Color.multiply的静态与实例方法效果不一样?

代码:
let a = new Color(100, 100, 100, 100)
let b = new Color(100, 100, 100, 100)
console.log("" + a)
console.log("" + a.multiply(b))
console.log("" + a)

a = new Color(100, 100, 100, 100)
b = new Color(100, 100, 100, 100)
console.log("" + Color.multiply(new Color(), a, b))

日志:
rgba(100, 100, 100, 100)
rgba(39, 39, 39, 39)
rgba(39, 39, 39, 39)
rgba(255, 255, 255, 255)

问题:
最后一条应该也是rgba(39, 39, 39, 39),看结果像是直接100*100了。
一开始一直算不对,一度以为我疯了,换成实例方法就对了。

/**

 * @en Multiplies the current color by the specified color.

 * @zh 将当前颜色乘以与指定颜色

 * @param other The specified color.

 */

public multiply (other: Color) {

    const r = ((this._val & 0x000000ff) * other.r) >> 8;

    const g = ((this._val & 0x0000ff00) * other.g) >> 8;

    const b = ((this._val & 0x00ff0000) * other.b) >> 8;

    const a = ((this._val & 0xff000000) >>> 8) * other.a;

    this._val = (a & 0xff000000) | (b & 0x00ff0000) | (g & 0x0000ff00) | (r & 0x000000ff);

    return this;

}

/**

 * @en Multiply each components of two colors. And save the results to out color.

 * @zh 逐通道颜色乘法

 */

public static multiply<Out extends IColorLike> (out: Out, a: Out, b: Out) {

    out.r = a.r * b.r;

    out.g = a.g * b.g;

    out.b = a.b * b.b;

    out.a = a.a * b.a;

    return out;

}

因为源码就是不一样的

1赞

刚才也找源码看了, 虽然没看懂为啥,但是大受震撼

这两份逻辑应该都没错,都有应用的需要,但在同一个函数名就不应该了,起码拆多一份接口出来嘛