Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
21
Task/Bitmap-Flood-fill/MiniScript/bitmap-flood-fill.mini
Normal file
21
Task/Bitmap-Flood-fill/MiniScript/bitmap-flood-fill.mini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
floodFill = function(bmp, x, y, targetColor, replacementColor)
|
||||
// Check if pixel is outside the bounds
|
||||
if not(0 < x < bmp.width) or not(0 < y < bmp.height) then return
|
||||
|
||||
// Check the current pixel color
|
||||
currentColor = bmp.pixel(x, y)
|
||||
if currentColor != targetColor then return
|
||||
|
||||
// Replace the color
|
||||
bmp.setPixel x, y, replacementColor
|
||||
// Recursively apply to adjacent pixels
|
||||
floodFill(bmp, x + 1, y, targetColor, replacementColor)
|
||||
floodFill(bmp, x - 1, y, targetColor, replacementColor)
|
||||
floodFill(bmp, x, y + 1, targetColor, replacementColor)
|
||||
floodFill(bmp, x, y - 1, targetColor, replacementColor)
|
||||
end function
|
||||
clear
|
||||
img = file.loadImage("Unfilledcirc.png")
|
||||
gfx.drawImage img, 0, 0
|
||||
floodFill gfx, 50, 50, "#FFFFFFFF", "#00FFFFFF"
|
||||
floodFill gfx, 100, 125, "#000000FF", "#0000FFFF"
|
||||
Loading…
Add table
Add a link
Reference in a new issue