void PerPixel(PixelCom p) { map [p.x, p.y] = 2; int index = SWTextureProcess.XYtoIndex(texSrcWidth, texSrcHeight, p.x, p.y); float m = SWTextureProcess.Match(texSrcColorBuffer [index], texSrcColorBuffer [p.colorFrom]); if (m <= tolerance) { SWTextureProcess.Brush_ApplyOnce(ref texColorBuffer [index], brush, 0); AddTask(p.x + 1, p.y, index); AddTask(p.x - 1, p.y, index); AddTask(p.x, p.y - 1, index); AddTask(p.x, p.y + 1, index); } }
void AddTask(int x, int y, int cfrom) { if (x < 0 || x >= map.GetLength(0)) { return; } if (y < 0 || y >= map.GetLength(1)) { return; } if (map [x, y] != 0) { return; } map [x, y] = 1; PixelCom p = new PixelCom(); p.x = x; p.y = y; p.colorFrom = cfrom; tasks.Add(p); }