ngx-color icon indicating copy to clipboard operation
ngx-color copied to clipboard

Get hex + alpha

Open MichaelPruefer opened this issue 4 years ago • 1 comments

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);
}

MichaelPruefer avatar Jun 15 '20 09:06 MichaelPruefer

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.

nzbin avatar Dec 09 '21 08:12 nzbin