Hi leute,
hab mich mal dran gemacht ein Paint-Programm für meinen WIZ zu coden, brauche jetzt allerding Hilfe, da meine Floodfill-Routine net hinhaut, sitze da schon seit ewiger Zeit dran :rant:
FUNCTION fill: x%,y%,rand,farbe
IF (pix_map[x][y] <> rand)
pix_map[x][y]=farbe
fill(x,y+1,rand,farbe)
fill(x,y-1,rand,farbe)
fill(x+1,y,rand,farbe)
fill(x-1,y,rand,farbe)
ENDIF
RETURN
ENDFUNCTION
Jetzt ist das im Endeffekt der Algorithmus der in Wikipedia zu finden ist, denke auch das der Code in C funzen würde, allerdings wenn ich compiliere und ausführe (GLBasic 7.250) dann beendet es das Programm wenn ich eine Fläche füllen möchte.
Meine Vermutung ist das GLBasic die Rekursion nicht mag, oder liegts woanders?
Bitte um schnelle Hilfe!
MfG
You have to be careful with too deep recursion, depends on stack-space.
Yes, that is already known to me, it's only the 1st Stage and it does not work. The depth test is added later when it is finally time to see what to do.
FUNCTION myFill: x,y,rand, farbe
local bufx[], bufy[]
dimpush bufx[], x
dimpush bufy[], y
while len(bufx[])
local x = bufx[-1]
local y = bufy[-1]
if pix_map[x-1][y]<> rand and pix_map[x-1][y]<>farbe // nicht nochmal mit farbe füllen!!
dimpush bufx[], x-1
dimpush bufy[], y
endif
...
wend
ENDFUNCTION
Hi "Kitty Hello"
vielen Dank für den Post, hat mich mal in die richtige Richtung gebracht :good:
mal sehen obs nun ein "Gimp" für den WIZ wird =D
MfG
Hau in die Tasten ;)