Published
Edited
Oct 22, 2021
3 stars
Also listed in…
Tips and Utilities
Insert cell
Insert cell
moonArray = ["🌕","🌖","🌗","🌘","🌑","🌒","🌓","🌔"]
Insert cell
function* animateMoon() {
let i=0;
while(true){
i++;
if(i>=moonArray.length){ i = 0}
yield moonArray[i]
}
}
Insert cell
animateMoon()
Insert cell
function* animateMoonSlower(msec){
let i =0;
while (true) {
yield new Promise(resolve => {
i++;
if(i>=moonArray.length){ i = 0}
setTimeout(() => resolve(moonArray[i]), msec);
});
}
}
Insert cell
animateMoonSlower(1000)
Insert cell
ossliate = Math.round(Math.sin(now*.001) * moonArray.length/2 + moonArray.length/2)
Insert cell
function* ossilateMoon(){
while(true){
yield moonArray[ossliate < moonArray.length? ossliate: 0]
}
}
Insert cell
ossilateMoon()
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