Skip to content

Instantly share code, notes, and snippets.

@dfosco
Created February 19, 2024 10:28
Show Gist options
  • Save dfosco/bff932833425795225951cd653618118 to your computer and use it in GitHub Desktop.
Save dfosco/bff932833425795225951cd653618118 to your computer and use it in GitHub Desktop.
Ducking Cool
function randomNum(min,max){
return Math.floor(Math.random()*(max-min+1)+min);
}
async function addImage() {
let viewport = await miro.board.viewport.get();
let variableHeight = (randomNum(0.6,1.2) * (viewport.height * 0.3));
const boardImage = await miro.board.createImage({
title: 'DuckDuckDuckDuck',
url: 'https://gist.github.com/dfosco/82e723bd575d58a8ed0a37a2198b3edf/raw/0be8390d95c2abb8e97858e2099e34de0e4b23f1/GOOSE-IT.png',
x: randomNum(viewport.x, viewport.width),
y: randomNum(viewport.y, viewport.height),
height: variableHeight,
rotation: randomNum(0,360)
})
;}
async function goToDucks() {
const ducks = await miro.board.get({ type: 'image', });
await miro.board.viewport.zoomTo(ducks);
}
Array.from({ length: randomNum(2,8) }, (x, i) => {
addImage();
});
goToDucks();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment