Skip to content

NaN RGB values if passing zero to interpolateRgb #114

@songololo

Description

@songololo

For some reason I am getting NaN values when trying to use zero with the RGB interpolator. Using 0.01 instead of zero seems to fix the problem:

const myColor = rgb(97, 80, 8, 1)
const myColorTransparent = rgb(97, 80, 8, 0.0)
const myColorMap = interpolateRgb(myColorTransparent, myColor)
console.log(color(myColorMap(0.0)))
// returns Rgb {r: NaN, g: NaN, b: NaN, opacity: 0}

const myColor = rgb(97, 80, 8, 1)
const myColorTransparent = rgb(97, 80, 8, 0.01)
const myColorMap = interpolateRgb(myColorTransparent, myColor)
console.log(color(myColorMap(0.0)))
// returns Rgb {r: 97, g: 80, b: 8, opacity: 0.01}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions