Public
Edited
May 26, 2024
Paused
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { addTooltips } from "@mkfreeman/plot-tooltip"
Insert cell
faStyle({ solid: true })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
rgbGamut = {
const acc = [];
for (const r of [...d3.range(0, 255, 10), 255]) {
for (const g of [...d3.range(0, 255, 10), 255]) {
for (const b of [...d3.range(0, 255, 10), 255]) {
const rgb = { r: r / 256, g: g / 256, b: b / 256, mode: "rgb" };

const hex = culori.formatHex(rgb);
const oklab = culori.oklab(rgb);
const oklch = culori.oklch(rgb);
const argb = 0xff000000 + r * 0x10000 + g * 0x100 + b;
const hct = MCU.Hct.fromInt(argb);
const x = Math.cos(toRadians(hct.hue)) * hct.chroma;
const y = Math.sin(toRadians(hct.hue)) * hct.chroma;

const tone = hct.tone;
const hue = hct.hue;
const chroma = hct.chroma;
const delta = hct.tone - oklab.l * 100;
const googlab = { l: tone / 100, a: x, b: y };

acc.push({
hex,
argb,
oklab,
oklch,
hct,
hue,
tone,
chroma,
googlab,
delta
});
}
}
}
return acc;
}
Insert cell
hclOklchChromaScalingFactor = _.maxBy(rgbGamut, (d) => d.hct.chroma).chroma /
culori.modeOklch.ranges.c[1]
Insert cell
Insert cell
tooltip = ({ oklch, hct }) => `HCT(${hct.tone.toFixed(0)}, ${hct.chroma.toFixed(
0
)}, ${hct.hue.toFixed(0)})
Oklch(${oklch.l.toFixed(2)}, ${oklch.c.toFixed(2)}, ${(oklch.h || 0).toFixed(
0
)})`
Insert cell
Insert cell
console.assert(black - rgbGamut.at(0).argb === 0)
Insert cell
console.assert(white - rgbGamut.at(-1).argb === 0)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more