Published
Edited
Feb 22, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
//field.appendChild(html`<b>hi</b>`)
// while(true){
// yield Promises.delay(1000, `Previous text: ${text}`);
// }
while(true){
yield Promises.delay(delay);
field.appendChild(createBox())
}
}
Insert cell
createBox = () => {
let randomX = Math.floor(Math.random() * width);
let randomY = Math.floor(Math.random() * 300);
let randomHeight = Math.floor(Math.random() * 100) + 10;
let randomWidth = Math.floor(Math.random()* 100) + 10;
let randomBackground = opencolorsarray[Math.floor(Math.random() * opencolorsarray.length)].color;
return html`<div
style="
position:absolute;
top:${randomY}px;
left:${randomX}px;
height:${randomHeight}px;
width:${randomWidth}px;
background-color: ${randomBackground}
"
class="box"
></div>
`
}
Insert cell
md`---
## Imports
`
Insert cell
import {opencolorsarray} from "@mattdzugan/open-color"

Insert cell
import {Button, Range} from "@observablehq/inputs"

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