Qbasicnews.com

Full Version: fill point maximum
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Heckbert fill proceeds scanline by scanline. Don't know how it fits into your classification. I once posted it for Jark at this forum,
http://forum.qbasicnews.com/viewtopic.ph...t=heckbert
In a stack the last item you push is the first you retrieve. A stack is Last In-First out (LIFO). In a queue the first item pushed is the first you Retrieve (FIFO).

I can also post a very simple RECURSIVE Hilbert curve algorithm. I remember you hating recursion.... :evil: Big Grin
Edited:
Code:
'Hilbert curve
DECLARE SUB Hilbert (r1%, r2%, level%)
SCREEN 12
PSET (0, 0)
clr% = 12
Hilbert 2, 0, 8
a$ = INPUT$(1)
END

SUB Hilbert (r1%, r2%, level%)
SHARED clr%
IF level% THEN
  Hilbert r2%, r1%, level% - 1
  LINE -STEP(r1%, r2%), clr%
  Hilbert r1%, r2%, level% - 1
  LINE -STEP(r2%, r1%), clr%
  Hilbert r1%, r2%, level% - 1
  LINE -STEP(-r1%, -r2%), clr%
  Hilbert -r2%, -r1%, level% - 1
END IF
END SUB
Heckbert fill...
line by line...
Hmm..
Didn't look at the code closely..... but.. it grows by lines, scanning the edges of each line, potentially reducing the size of the array needed? Hmmm...

Neat... Can't test it now though or my computer will freeze......

My algorithm is a FIFO queue anyways actually.. Size of array can't be made smaller with a slower algorithm, can it? (er, except scanning the 2D array each time)

I think I'll try to make that an iterative algorithm.....
I once thought about reducing the stack size by checking it for redundant entries. The same point-direction-line or whatever the stack stores can be generated twice by explorating the plan from dfferent points. Also a point being filled can invalidate some existant stack entries.

All that would be very slow (and difficult to implement) but this way the stack could be kept to a minimum.
Pages: 1 2 3