Skip to content

Instantly share code, notes, and snippets.

@jasonmoo
Created January 4, 2014 23:07
Show Gist options
  • Select an option

  • Save jasonmoo/8262046 to your computer and use it in GitHub Desktop.

Select an option

Save jasonmoo/8262046 to your computer and use it in GitHub Desktop.
recursive fill function
function fill(x,y) {
if (c.getImageData(x,y, 1,1).data[0] !== 0) {
c.fillRect(x,y, 1,1);
fill(x-1, y-1); fill(x, y-1); fill(x+1, y-1);
fill(x-1, y); /* current */ fill(x+1, y);
fill(x-1, y+1); fill(x, y+1); fill(x+1, y+1);
}
}
@jasonmoo
Copy link
Copy Markdown
Author

jasonmoo commented Jan 4, 2014

wildly inefficient but neat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment