ngx-color
ngx-color copied to clipboard
Get hex + alpha
Is it possible to retrieve the alpha value when using color.hex on ColorEvent?
it would be better than doing
let hexValue = colorEvent.color.hex || '';
if (hexValue.length === 7) {
hexValue += Math.round(colorEvent.color.rgb.a * 255).toString(16);
}
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.