Public
Edited
Mar 6, 2023
Insert cell
Insert cell
start = ({
...culori.okhsl("#1b87aa"),
l: 0.7,
s: 0.15
})
Insert cell
startColorBlue = culori.okhsl("#cdcdd1")
Insert cell
endColorRed = culori.okhsl("#ac004f")
Insert cell
saveColor = ({
...culori.okhsl("#cdcdd1"),
l: 0.95,
s: 0.1
})
Insert cell
mid1 = ({ ...culori.okhsl("#d5cdb9"), l: 0.3, s: 0.2 })
Insert cell
mid2 = ({ ...culori.okhsl("#df7c18"), s: 0.9, l: 0.4 })
Insert cell
dangerColor = ({
...endColorRed,
s: 1,
l: 0.65
})
Insert cell
veryMurky = ({
...culori.okhsl("#ae49a2"),
s: 1,
l: 0.8
})
Insert cell
gradientDisplay(gradient, 10)
Insert cell
swatches(culori.samples(10).map(gradient))
Insert cell
gradient = culori.interpolate(
[saveColor, start, mid1, mid2, dangerColor],
"oklab",
culori.interpolatorSplineBasis
)
Insert cell
Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(culori.samples(20).map(gradient), { y: "s" })
]
})
Insert cell
Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(culori.samples(20).map(gradient), { y: "v" })
]
})
Insert cell
Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(culori.samples(20).map(gradient), { y: "h" })
]
})
Insert cell
Insert cell
culori = import("https://cdn.skypack.dev/culori@3")
Insert cell
gradientDisplay = (colors, numberOfSamples = 5) => {
const id = nanoid.nanoid(5);
let gradientFixPoints = culori
.samples(numberOfSamples)
.map(colors);

return html`

<svg width="250" height="32">
<defs>
<linearGradient id="${id}">
${gradientFixPoints
.map(culori.formatHex)
.map(
(col, i) =>
`<stop offset="${
i * (100 / (numberOfSamples - 1))
}%" stop-color="${col}" />`
)}
</linearGradient>
</defs>
<rect x="0" y="0" width="100%" height="100%" fill="url(#${id})" />
</svg>
<pre>${gradientFixPoints.map(culori.formatHex).join(", ")}</pre>

`;
}
Insert cell
import { swatches } from "@nzzvisuals/dataviz-colors"
Insert cell
nanoid = import("https://cdn.skypack.dev/nanoid")
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