Public
Edited
Apr 9, 2023
Insert cell
md`# Color Palettes`
Insert cell
html`
<style>
.container {
display: flex;
// gap: .5rem;
}
.color-block {
width: 50px;
height: 50px;
display: flex;
flex-direction: column;
color: white;
text-shadow: 1px 1px black;
}
</style>
`
Insert cell
function colorRow(colors) {
return html`<div class="container">${colors.map(
(color, i) =>
`<div class="color-block" style="background-color: ${color};"></div>`
)}</div>`;
}
Insert cell
colorRow(allColors)

Insert cell
paletteAngles = [
0, 30, 45, 60, 75, 120, 165, 180, 195, 210, 240, 270, 285, 300, 330
]
Insert cell
paletteColors = paletteAngles.map((angle) => `hsl(${angle}deg 100% 50%)`)
Insert cell
colorRow(paletteColors)
Insert cell
darkPalette = paletteAngles.map((angle) => `hsl(${angle}deg 100% 33.3%)`)
Insert cell
colorRow(darkPalette)
Insert cell
lightPalette = paletteAngles.map(angle => `hsl(${angle}deg 100% 80%)`)
Insert cell
colorRow(lightPalette)
Insert cell
desaturatedPalette = paletteAngles.map(angle => `hsl(${angle}deg 16.6% 66.7%)`)
Insert cell
colorRow(desaturatedPalette)
Insert cell
fullGreys = _.range(0, 101, 100/16).map(percent => `hsl(0deg 0% ${percent}%)`)
Insert cell
colorRow(fullGreys)
Insert cell
colorRow(radians)
Insert cell
radians = _.range(0, 20).map(rad => culori.formatHex({ mode: 'lch', l: 75, c: 100, h: rad * phi / 2 / (2 * Math.PI) * 360}))
Insert cell
allColors = _.range(0, 360, 15).map(angle => `hsl(${angle}deg 100% 50%)`)
Insert cell
phi = (1 + Math.sqrt(5)) / 2
Insert cell
culori = require('culori')
Insert cell
_ = require('lodash')
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