We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f6d7864 + c175da7 commit c503a35Copy full SHA for c503a35
algorithm/category.json
@@ -58,6 +58,7 @@
58
"etc": {
59
"name": "Uncategorized",
60
"list": {
61
+ "flood_fill": "Flood Fill"
62
}
63
64
algorithm/etc/flood_fill/desc.json
@@ -0,0 +1,9 @@
1
+{
2
+ "Flood Fill": "Flood fill, also called seed fill, is an algorithm that determines the area connected to a given node in a multi-dimensional array",
3
+ "References": [
4
+ "<a href='https://en.wikipedia.org/wiki/Flood_fill'>Wikipedia</a>"
5
+ ],
6
+ "files": {
7
+ "flood_fill": ""
8
+ }
9
+}
algorithm/etc/flood_fill/flood_fill/code.js
@@ -0,0 +1,20 @@
+function FloodFill(i, j, oldColor, newColor) {
+
+ if (i < 0 || i >= G.length || j < 0 || j >= G[i].length) return;
+ if (G[i][j] != oldColor) return;
+ // set the color of node to newColor
+ G[i][j] = newColor;
+ tracer._select(i, j)._wait();
10
+ tracer._notify(i, j, G[i][j])._wait();
11
12
+ // next step four-way
13
+ FloodFill(i + 1, j, oldColor, newColor);
14
+ FloodFill(i - 1, j, oldColor, newColor);
15
+ FloodFill(i, j + 1, oldColor, newColor);
16
+ FloodFill(i, j - 1, oldColor, newColor);
17
18
19
+FloodFill(4, 4, '-', 'a');
20
algorithm/etc/flood_fill/flood_fill/data.js
@@ -0,0 +1,13 @@
+var tracer = new Array2DTracer ();
+var G = [
+ ['#', '#', '#', '#', '#', '#', '#', '#', '#'],
+ ['#', '-', '-', '-', '#', '-', '-', '-', '#'],
+ ['#', '-', '-', '#', '-', '-', '-', '-', '#'],
+ ['#', '#', '#', '-', '-', '-', '#', '#', '#'],
+ ['#', '-', '-', '-', '-', '#', '-', '-', '#'],
+ ['#', '#', '#', '#', '#', '#', '#', '#', '#']
+];
+tracer._setData(G);
js/script.js
@@ -241,11 +241,11 @@ $.getJSON('./algorithm/category.json', function (data) {
241
for (var category in list) {
242
(function (category) {
243
var $category = $('<button class="category">')
244
- .append('<i class="fa fa-fw fa-caret-down">')
+ .append('<i class="fa fa-fw fa-caret-right">')
245
.append(list[category].name);
246
$category.click(function () {
247
$('[data-category="' + category + '"]').toggleClass('collapse');
248
- $(this).find('i.fa').toggleClass('fa-caret-down fa-caret-right');
+ $(this).find('i.fa').toggleClass('fa-caret-right fa-caret-down');
249
});
250
$('#list').append($category);
251
var subList = list[category].list;
0 commit comments