diff --git a/demo/app/components.tsx b/demo/app/components.tsx index 20dcaa3..ca5d468 100644 --- a/demo/app/components.tsx +++ b/demo/app/components.tsx @@ -27,6 +27,7 @@ export function ColorConvert() {
The nearest color is determined by simple Euclidian distance using a diff --git a/demo/src/ColorSlider.tsx b/demo/src/ColorSlider.tsx index ffe6a0b..d571d53 100644 --- a/demo/src/ColorSlider.tsx +++ b/demo/src/ColorSlider.tsx @@ -15,12 +15,14 @@ const toGradientStops = (colorStops: Color[]) => { }; export default function ColorSlider({ + label = "Select color", className, colorStops, scaleImage, value: valueFromProps, onChange, }: { + label?: string; className?: string; colorStops?: Color[]; scaleImage?: string; @@ -35,18 +37,20 @@ export default function ColorSlider({ return { "--color-gradient": `url("${scaleImage}")`, } as React.CSSProperties; - } else { + } else if (colorStops) { const colorString = toGradientStops(colorStops).join(", "); return { "--color-gradient": `linear-gradient(to right, ${colorString})`, } as React.CSSProperties; + } else { + return {}; } }, [colorStops, scaleImage]); return (
A TypeScript library for working with Turbo, an improved rainbow colormap for visualization. Turbo is often used for depth maps. This library includes the ability to “uncolormap” Turbo, converting values back to normalized floats or grayscale intensities. In addition to the library, you can also use this demo page to perform quick color and image conversions.
This library generates more faithful values than the d3 approximation of Turbo found in d3-scale-chromatic.
See the README on GitHub.
npm install turbo-colormap
Two-way conversion between grayscale intensity and Turbo.
Some tools expect grayscale depth maps. Load images into the area below to convert between grayscale and Turbo images. Conversion is done client-side; all data stays in your browser.
tap or drag & drop Turbo image
tap or drag & drop grayscale image
This demo will consume a little CPU and needs to be enabled first.
Snap arbitrary colors to the indexed Turbo palette. This can yield surprising results with much of the sRGB color space; it’s mostly useful for interpreting visualizations exported with an approximation of Turbo or a lossy format like JPEG, where the colors won’t be in the Turbo lookup table.
The nearest color is determined by simple Euclidian distance using a k-d tree.
A TypeScript library for working with Turbo, an improved rainbow colormap for visualization. Turbo is often used for depth maps. This library includes the ability to “uncolormap” Turbo, converting values back to normalized floats or grayscale intensities. In addition to the library, you can also use this demo page to perform quick color and image conversions.
This library generates more faithful values than the d3 approximation of Turbo found in d3-scale-chromatic.
See the README on GitHub.
npm install turbo-colormap
Two-way conversion between grayscale intensity and Turbo.
Some tools expect grayscale depth maps. Load images into the area below to convert between grayscale and Turbo images. Conversion is done client-side; all data stays in your browser.
tap or drag & drop Turbo image
tap or drag & drop grayscale image
This demo will consume a little CPU and needs to be enabled first.
Snap arbitrary colors to the indexed Turbo palette. This can yield surprising results with much of the sRGB color space; it’s mostly useful for interpreting visualizations exported with an approximation of Turbo or a lossy format like JPEG, where not every pixel will be in the Turbo lookup table.
The nearest color is determined by simple Euclidian distance using a k-d tree.