d3 / d3-color

Color spaces! RGB, HSL, Cubehelix, CIELAB, and more.
https://d3js.org/d3-color
ISC License
400 stars 91 forks source link

Alpha value of 0 breaks rgb #74

Closed nickofthyme closed 4 years ago

nickofthyme commented 4 years ago

When using an alpha value with d3.rgb, via rgba or hsla colors strings, the color values return NaN.

Is this expected behavior?

tested on d3-color@1.4.0

d3.rgb('hsla(240,100%,25%,0)');

// returns
{
  r: NaN,
  b: NaN,
  g: NaN,
  opacity: 0,
}
d3.rgb('rgba(0,0,0,0)');

// returns
{
  r: NaN,
  b: NaN,
  g: NaN,
  opacity: 0,
}

Also interesting to note that the behavior of non-zero, but close to zero, alpha values return the expected color.

d3.rgb('rgba(0,0,0,0.001)');

// returns
{
  r: 0,
  b: 0,
  g: 0,
  opacity: 0.001,
}
nickofthyme commented 4 years ago

duplicate of #52