Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
23
Task/Bitmap-Flood-fill/Phix/bitmap-flood-fill.phix
Normal file
23
Task/Bitmap-Flood-fill/Phix/bitmap-flood-fill.phix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
function ff(sequence img, integer x, integer y, integer colour, integer 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, integer y, integer 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