Published
Edited
Jun 6, 2021
Fork of Kaboom 0.5.1
Insert cell
Insert cell
Insert cell
<canvas id="kb"></canvas>

Insert cell
K = KABOOM({
width: 480, // width of canvas
height: 480, // height of canvas
canvas: document.getElementById("kb"),
clearColor: [0,0,0,1],
crisp: true
});
Insert cell
{
K.scene("main", () => {
// for(let i =0; i < numTiles; i++){
// K.add([
// K.sprite("tiles",{
// frame: i
// }),
// K.scale(4),
// K.pos(K.rand(0,420), K.rand(0,420))
// ])
// }
K.render(()=>{
K.drawSprite("tiles", {
pos: K.vec2(240),
scale: K.time(),
origin: "center",
rot: K.time(),
frame: frame,
});
})
});

K.start("main");
}
Insert cell
tiles = K.loadSprite("tiles", await FileAttachment("colored_transparent_packed.png").url(),{
sliceX: 48,
sliceY: 22
})
Insert cell
numTiles = 1056

Insert cell
frame = Math.floor(Math.random() * numTiles)
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