Author Topic: Fill Fast Line algorithm  (Read 979 times)

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 145
  • UNUS SED LEO
    • View Profile
Fill Fast Line algorithm
« on: 2018-Aug-10 »
After i have grabbing with both hands in the forum a small summer gift (I hope it will be appreciated).
You find the scanline floodfill algorithm using stack instead of recursion.
I converted the version I found in internet from C++ to GlBasic.
Compared to the standard version this is much faster about 10-15 times.
When you start the program for the first 10 seconds, the standard (more slow) version is executed and  after the scanline version.
The program uses my FASTMEM2SPRITE version (which you already sent a while ago and which I have now improved), but you can comment the command and activate the standard MEM2SPRITE to appreciate even more the change of speed.
Let me know

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2556
    • View Profile
Re: Fill Fast Line algorithm
« Reply #1 on: 2018-Aug-10 »
Cool, thanks Qedo!  :good:
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline dreamerman

  • Mr. Polyvector
  • ***
  • Posts: 212
    • View Profile
    • my personal website
Re: Fill Fast Line algorithm
« Reply #2 on: 2018-Aug-13 »
Nice, good to have such code ready for use in future. Did you tried other filling algorithms, even just to compare speed? Don't know what impact have those DIMPUSH / DELETE commands.
Check my source code editor for GLBasic - link

Offline Qedo

  • Mr. Polyvector
  • ***
  • Posts: 145
  • UNUS SED LEO
    • View Profile
Re: Fill Fast Line algorithm
« Reply #3 on: 2018-Aug-17 »
dreamerman, I searched the internet for the best filling algorithm and implemented it in GLB. I do not think there are others, but I can be wrong.
At the beginning I was very doubtful about the efficiency of DIMPUSH / DELETE and the FOREACH / NEXT cycle but I have to say that I'm not a real bottleneck. To get rid of all doubts it would be interesting to implement it in c ++ but for the moment I am satisfied with this version.