Skip to content

Instantly share code, notes, and snippets.

@galElmalah
Created May 26, 2020 13:13
Show Gist options
  • Save galElmalah/b71096146695cea31ec814c3fed18b6c to your computer and use it in GitHub Desktop.
Save galElmalah/b71096146695cea31ec814c3fed18b6c to your computer and use it in GitHub Desktop.
painting each action
let ticks = 0;
const speed = 50;
bubbleSort(randomArray, (action) => {
ticks++;
setTimeout(() => {
actionsMap[action.type](action, arrayMembers);
ctx.clearRect(0, 0, innerWidth, innerHeight);
drawAll(arrayMembers);
arrayMembers.forEach((m) => m.resetColor());
}, ticks * speed);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment