Public
Edited
Dec 26
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
oppositeCubeColor = ({
mode: color.mode,
r: 1 - color.r,
g: 1 - color.g,
b: 1 - color.b
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
cpcResult = cpc.findOppositeColor(
culori.itp(color),
culori.itp(origin),
inGamut(culori.inGamut(color.mode))
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
scale = cpc.cartesianColorScale([culori.itp(color), culori.itp(origin)])
Insert cell
Insert cell
Insert cell
Insert cell
gamutStretchedScale = scale.stretch(inGamut(culori.inGamut(color.mode)))
Insert cell
Insert cell
Insert cell
Insert cell
edge = gamutStretchedScale(0)
Insert cell
Insert cell
edgeToOrigin = cpc.cartesianColorScale([edge, culori.itp(origin)])
Insert cell
Insert cell
Insert cell
closestPointOnScale = edgeToOrigin.invert(culori.itp(color))
Insert cell
Insert cell
oppositeEdge = gamutStretchedScale(1)
Insert cell
Insert cell
oppositeEdgeToOrigin = cpc.cartesianColorScale([
oppositeEdge,
culori.itp(origin)
])
Insert cell
Insert cell
Insert cell
result = oppositeEdgeToOrigin(closestPointOnScale)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sRgbGamut = ({
name: "sRGB",
cssGamut: "srgb",
fitsGamut: culori.displayable
})
Insert cell
p3Gamut = ({
name: "Display-P3",
cssGamut: "display-p3",
fitsGamut: culori.inGamut("p3")
})
Insert cell
diff = culori.differenceItp()
Insert cell
formatHexOrCss = (color) =>
culori.displayable(color) ? culori.formatHex(color) : culori.formatCss(color)
Insert cell
findOppositeColor = (vertex, { cssGamut, fitsGamut }) => {
const color = culori.parse(vertex.toCssString(cssGamut));
const oppositeColor = culori.p3(
cpc.findOppositeColor(
culori.itp(color),
culori.itp(origin),
(color) =>
diff(culori.itp(culori.xyz65(color)), color) < 0.0001 && fitsGamut(color)
)
);

return { oppositeColor, deltaE: Math.round(diff(color, oppositeColor)) };
}
Insert cell
inGamut = (fitsGamut) => (color) =>
diff(culori.itp(culori.xyz65(color)), color) < 0.0001 && fitsGamut(color)
Insert cell
Insert cell
color && origin && dragRotateGroups.clear()
Insert cell
Insert cell
culori = import("culori@4")
Insert cell
import { ramp, p3Swatch } from "@devgru/color-scale-utils"
Insert cell
import { cg } from "@devgru/cg-latest"
Insert cell
import { cpc } from "@devgru/cpc-latest"
Insert cell
import { colorPicker } from "@devgru/color-picker"
Insert cell
import {
colorSpace3D,
colorToCompressedItpPoint,
colorToRotatedP3Point,
dragRotateGroups
} from "@devgru/color-space-3d"
Insert cell
import { itpDisclaimer } from "@devgru/ictcp"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more