Public
Edited
Dec 15, 2023
1 fork
Insert cell
Insert cell
<div id="frame"><div id="display">${buildSpels(verseSpanned).spansStr}</div></div>
Insert cell
play(NB)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
<pre id="verse">
rich scarlet
deepens
herb path
faint turquoise
fills
mountain window

envy you
butterfly
through dreams
under flowers

wine flying
</pre>
Insert cell
Insert cell
verseSpanned = html`${await addSpansTo(verse)}`
Insert cell
verseWidth = pxToVw(
Array.from(verseSpanned.children).reduce(
(a, b) => Math.max(a, b.offsetLeft + b.offsetWidth),
0
)
)
Insert cell
verseHeight = pxToVw(
Array.from(verseSpanned.children).reduce(
(a, b) => Math.max(a, b.offsetTop + b.offsetHeight),
0
)
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
scores = [
readThrough_linear,
toggleAll,
parallel_segments,
path_fading,
// randomly chosen segments will be injected into the following on play()
readThrough_path,
readThrough_path
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
<h2>CSS</h2>
<style>

@font-face {
font-family: 'NotoSerif';
src: local('NotoSerif'),
url(${await FileAttachment("NotoSerif-Regular.woff2").url()}) format('woff2'),
url(${await FileAttachment("NotoSerif-Regular.woff").url()}) format('woff'),
url(${await FileAttachment("NotoSerif-Regular.ttf").url()}) format('ttf')
}

:root {
--ffam: NotoSerif, serif;
--fsize: 2.3vw;
}

#frame {
position: relative;
background-color: ghostwhite;
padding: 1vw;
width: max-content;
}

#display {
position: relative;
background-color: floralwhite;
font-family: var(--ffam);
font-size: var(--fsize);
color: slate;
cursor: none;
overflow: hidden;
width: 54.9163179916318vw; /* This value is calculated in the verseWidth cell, manually */
height: 44.8744769874477vw; /* This value is calculated in the verseHeight cell, manually */
}

#verse {
margin: 0;
font-family: var(--ffam);
font-size: var(--fsize);
}

.text {
position: absolute;
opacity: 0;
transition: opacity 1.5s ease-in-out;
}

.text.visible {
opacity: 1;
}

</style>
Insert cell
Insert cell
pxToVw = (px) => px * (100 / document.documentElement.clientWidth)
Insert cell
Insert cell
Insert cell
wfJSON = ({
linear: await FileAttachment("wf_linear@2.json").json(),
parallel: await FileAttachment("wf_parallel@1.json").json(),
path: await FileAttachment("wf_path@1.json").json()
})
Insert cell
Insert cell
import {
cleanCsMd, // this import not needed for compilation; only needed if explicitly called in your notebook
compileCsMd
} from "@shadoof/coffeescript-markdown-in-observable"
Insert cell
NB = ({
buildSpels, // not used in the CoffeeScript but the ref here ensures that spels are built by Observable
spels,
readThrough_rdnPath,
scores,
Promises
})
Insert cell
CS = require("coffeescript")
Insert cell
Insert cell
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