Published
Edited
Jun 19, 2022
1 star
Also listed in…
Tips and Utilities
Insert cell
# Hello Color JS!
Insert cell
Insert cell
color = (await import('https://cdn.skypack.dev/color@4.2.3?min')).default
Insert cell
colors = {
const a = color('rgb(255, 255, 255)')
const b = color({r: 255, g: 255, b: 255})
const c = color.rgb(255, 255, 255)
const d = color.rgb([255, 255, 255])
yield {a,b,c,d}
}
Insert cell
colors.a.hsl().string()
Insert cell
colors.b.cmyk().round().array()
Insert cell
sample_color = color('#7743CE').alpha(0.5).lighten(0.5);
Insert cell
{
const cc = color("purple")
yield html`<div style="background-color:${cc.alpha(alphaRange).lighten(lightenRange)}; padding: 20px;"></div>`
}
Insert cell
viewof alphaRange = Inputs.range([0, 1], {label: "Alpha", step: .1})
Insert cell
viewof lightenRange = Inputs.range([0, 1], {label: "Lighten", step: .1})
Insert cell
{
const cc = color("purple")
yield html`<div style="background-color:${cc.mix(color("yellow"), mixRange)}; padding: 20px;"></div>`

}
Insert cell
viewof mixRange = Inputs.range([0, 1], {label: "Mix", step: .1})
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