Skip to content

Instantly share code, notes, and snippets.

@binarymax
binarymax / canvasfloodfill.js
Created November 14, 2012 12:36
Javascript Canvas FloodFill functions
//MIT License
//Author: Max Irwin, 2011
//Floodfill functions
function floodfill(x,y,fillcolor,ctx,width,height,tolerance) {
var img = ctx.getImageData(0,0,width,height);
var data = img.data;
var length = data.length;
var Q = [];
var i = (x+y*width)*4;