Add files via upload

This commit is contained in:
slweeb 2022-07-06 19:15:42 -04:00 committed by GitHub
parent d3f5b2b55d
commit a0da3cc160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 42 additions and 0 deletions

42
mods/fill_script.js Normal file
View File

@ -0,0 +1,42 @@
function FillTool(x,y)
{
if (!isEmpty(x,y))
{
oldElement = pixelMap[x][y].element;
}
else
{
oldElement = undefined;
}
Fill(x, y, oldElement);
}
function Fill(x, y, oldElement)
{
if (x < 0 || x >= width || y < 0 || y >= height) return;
if (pixelMap[x][y] !== undefined && oldElement !== undefined)
{
if (pixelMap[x][y].element != oldElement) return;
}
else
{
if (pixelMap[x][y] != oldElement) return;
}
var index = currentPixels.indexOf(pixelMap[x][y]);
if (index > -1)
{
currentPixels.splice(index, 1);
}
currentPixels.push(new Pixel(x, y, currentElement));
Fill(x + 1, y, oldElement);
Fill(x - 1, y, oldElement);
Fill(x, y + 1, oldElement);
Fill(x, y - 1, oldElement);
}
// Example: Fill(10, 10, pixelMap[10][10].element);