Open MichaelPruefer opened 4 years ago
I am also confused with this issue. It's really inconvenient without hex8 format. I have solved it with @ctrl/tinycolor
which used by ngx-color
.
new TinyColor(e.color.rgb).toHex8String()
You can check the colorpicker example.
This still persists, with how amazing this library is, this is a weird 'feature'
For anyone else who ran into this, this is the method that actually worked for me
public getRGBWithAlphaFromColorChangeEvent(event: ColorEvent) {
let hexValue = event.color.hex || '';
if (hexValue.length === 7) {
const alphaHex = Math.round(event.color.rgb.a * 255).toString(16).padStart(2, '0');
hexValue += alphaHex;
}
return hexValue;
}
Is it possible to retrieve the alpha value when using color.hex on ColorEvent?
it would be better than doing