TinyColor icon indicating copy to clipboard operation
TinyColor copied to clipboard

toString is returning rgba value but toHexString is returning a different value

Open ivikash opened this issue 6 years ago • 2 comments

Hi,

.toHexString() is not returning the expected value. Attaching a runkit.

https://runkit.com/embed/dhv39902sm0k

var tinycolor2 = require("tinycolor2")
const sheetsDefault = "#00857A"
const color =
console.log(tinycolor2(sheetsDefault).setAlpha(0.5).toString())
console.log(tinycolor2(sheetsDefault).setAlpha(0.5).toHexString())

ivikash avatar Apr 10 '19 00:04 ivikash

It seems the library doesn't have support for the Alpha channel in HEX values @ivikash. But in theory, is returning the correct value.

davegomez avatar Nov 03 '20 16:11 davegomez

@ivikash just noticed that you are not using the toHex8String method.

var tinycolor2 = require("tinycolor2")
const sheetsDefault = "#00857A"
console.log(tinycolor2(sheetsDefault).setAlpha(0.5).toString()).       // "rgba(0, 133, 122, 0.5)" 
console.log(tinycolor2(sheetsDefault).setAlpha(0.5).toHex8String()).   // "#00857a80"

davegomez avatar Nov 04 '20 20:11 davegomez