Public
Edited
Apr 29, 2024
Insert cell
Insert cell
colorjs = import("https://colorjs.io/dist/color.js")
Insert cell
Color = colorjs.default
Insert cell
colorcodes = new Color("#000").steps("#fff", {space: "oklab", outputSpace: "srgb", steps: 12}).map(x => x.toString({format: "hex"}))
Insert cell
Insert cell
scalenames = ['C', 'Df', 'D', 'Ef', 'E', 'F', 'Gf', 'G', 'Af', 'A', 'Bf', 'B']
Insert cell
scale = {
let s = {}
scalenames.forEach((n, i) => s[n] = colorcodes[i])
s['Fs'] = s['Gf']
return s
}
Insert cell
Cmajor = ['C', 'D', 'E', 'F', 'G', 'A', 'B'].map(n => scale[n])
Insert cell
function showScale(scale) {
return htl.html`<div style="border: 1px solid black">
${scale.map(c => html`<div style="background: ${c}; height: 30px"></div>`)}
</div>
`
}
Insert cell
Insert cell
Cminor = notes(['C', 'D', 'Ef', 'F', 'G', 'Af', 'Bf'])
Insert cell
showScale(Cminor)
Insert cell
cofCc = ['C', 'G', 'D', 'A', 'E', 'B', 'Fs'].map(n => scale[n])
// circle of fifth C clockwise
Insert cell
Insert cell
cofCcc = ['C', 'F', 'Bf', 'Ef', 'Af', 'Df', 'Gf'].map(n => scale[n])
// circle of fifth C counter-clockwise
Insert cell
Insert cell
function notes(symbols) {
return symbols.map(s => scale[s])
}
Insert cell
ionian = notes(['F', 'C', 'G', 'D', 'A', 'E', 'B'])
Insert cell
Insert cell
lydian = notes(['C', 'G', 'D', 'A', 'E', 'B', 'Fs'])
Insert cell
Insert cell
Insert cell
showScale(mixolydian)
Insert cell
aeolian = notes(['Af', 'Ef', 'Bf', 'F', 'C', 'G', 'D'])
Insert cell
showScale(aeolian)
Insert cell
dorian = notes(['Ef', 'Bf', 'F', 'C', 'G', 'D', 'A'])
Insert cell
showScale(dorian)
Insert cell
phrygian = notes(['Df', 'Af', 'Ef', 'Bf', 'F', 'C', 'G'])
Insert cell
showScale(phrygian)
Insert cell
locrian = notes(['Gf', 'Df', 'Af', 'Ef', 'Bf', 'F', 'C'])
Insert cell
showScale(locrian)
Insert cell
Insert cell
tangram(ionian)
Insert cell
tangram(dorian)
Insert cell
tangram(phrygian)
Insert cell
tangram(lydian)
Insert cell
tangram(mixolydian)
Insert cell
tangram(aeolian)
Insert cell
tangram(locrian)
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