angular-material-components icon indicating copy to clipboard operation
angular-material-components copied to clipboard

toRgbString doesn't show correct alpha value

Open lorenzoB07 opened this issue 3 years ago • 1 comments

The function toRgbString of class Color doesn't show correct alpha value. The function return a string like rgb(r,g,b) or rgba(r,g,b,1).

public toRgbString(): string {
        return (this.a === 1) ?
            "rgb(" + Math.round(this.r) + ", " + Math.round(this.g) + ", " + Math.round(this.b) + ")" :
            "rgba(" + Math.round(this.r) + ", " + Math.round(this.g) + ", " + Math.round(this.b) + ", " + this.roundA + ")";
    }

Is possible that "this.roundA" has to be changed with "this.a"?

public toRgbString(): string {
        return (this.a === 1) ?
            "rgb(" + Math.round(this.r) + ", " + Math.round(this.g) + ", " + Math.round(this.b) + ")" :
            "rgba(" + Math.round(this.r) + ", " + Math.round(this.g) + ", " + Math.round(this.b) + ", " + this.a + ")";
    }

lorenzoB07 avatar May 13 '21 10:05 lorenzoB07

I face the same problem: for example, alpha 0.26 is shown 0 On screen: alpha .54 is shown 1 image

ArfyFR avatar Dec 15 '22 13:12 ArfyFR