Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Bitmap-Flood-fill/Phix/bitmap-flood-fill.phix
Normal file
26
Task/Bitmap-Flood-fill/Phix/bitmap-flood-fill.phix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
-- demo\rosetta\Bitmap_FloodFill.exw (runnable version)
|
||||
include ppm.e -- blue, green, read_ppm(), write_ppm() (covers above requirements)
|
||||
|
||||
function ff(sequence img, integer x, y, colour, target)
|
||||
if x>=1 and x<=length(img)
|
||||
and y>=1 and y<=length(img[x])
|
||||
and img[x][y]=target then
|
||||
img[x][y] = colour
|
||||
img = ff(img,x-1,y,colour,target)
|
||||
img = ff(img,x+1,y,colour,target)
|
||||
img = ff(img,x,y-1,colour,target)
|
||||
img = ff(img,x,y+1,colour,target)
|
||||
end if
|
||||
return img
|
||||
end function
|
||||
|
||||
function FloodFill(sequence img, integer x, y, colour)
|
||||
integer target = img[x][y]
|
||||
return ff(img,x,y,colour,target)
|
||||
end function
|
||||
|
||||
sequence img = read_ppm("Circle.ppm")
|
||||
img = FloodFill(img, 200, 100, blue)
|
||||
write_ppm("FloodIn.ppm",img)
|
||||
img = FloodFill(img, 10, 10, green)
|
||||
write_ppm("FloodOut.ppm",img)
|
||||
Loading…
Add table
Add a link
Reference in a new issue