Author Topic: My Axe flood fill algorithm. [tutorial WIP]  (Read 2831 times)

0 Members and 1 Guest are viewing this topic.

Offline c4ooo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
My Axe flood fill algorithm. [tutorial WIP]
« on: March 10, 2015, 10:03:06 pm »
This was originally intended as a tutorial, but it never worked out like a tutorial so lie just post the code and comment on what it does.

So i was bored in math class and decided to implement a flood fill algorithm. It was actually much easier then i though  :w00t:
This is probably not the most efficient flood fill out there, as i thought of it myself . So yea: (ps the algorithm requires a second 768 (786?) byte buffer.) (pps i thought of the algorithm my self but it may be pretty standard  :-\ )
It seems pretty fast to me, but i don't know how fast it is compared to others. Ile try to post pics soon. So here is the code:
Code: [Select]
.FloodFill
.PROGRAM START, CALLS FLOOD FILL ON CORDS 48,32
DiagnosticOff
Full
ClrDraw^rr
FLOODFILL(48,32)
DispGraph
Text(0,0,"Over"
Repeat getKey
End
Return
Lbl FLOODFILL
r1->X
r2->Y
0->D+1->Z
Pxl-On(X,Y)
Pxl-On(X,Y)^r
Repeat getKey(1)
If HIT(Z)
TURN()->Z
!If Z
JUMP()
!If Z
Return
End
End
End
MOVEX()->X
MOVEY()->Y
D+1^1024-D
!If D
DispGraph
End
End
Return
Lbl JUMP
For(F,0,95)
For(G,0,63)
If pal-Test(F,G)^r
F->X
G->Y
TURN()->Z
if Z
Return
End
End
End
End
0->Z
Return
Lbl TURN
For(T,1,4
!If HIT(T)
T
Return
End
End
0
Return
Lbl HIW
MOVEX(r1)->I
MOVEY(r1)->J
If pxl-Test(I,J)??I<0??I>95??J<0??J>63
1
Return
End
0
Return
Lbl MOVEX
If r1=1
x+1
Return
ElseIf r1=3
X-1
Return
End
x
Return
Lbl MOVEY
if r1=2
Y-1
Return
ElseIf r1=4
Y+1
Return
End
Y
Return
Few that was long… now i have to indent and comment the code!  :P
« Last Edit: March 12, 2015, 06:32:28 pm by c4ooo »
-German Kuznetsov
The impossible chemical compound.