Re: vga pages or lack the

 BBS: Inland Empire Archive
Date: 06-13-92 (21:59)             Number: 193
From: MATT PRITCHARD @ 930/21      Refer#: NONE
  To: MATT HECK                     Recvd: NO  
Subj: Re: vga pages or lack the      Conf: (1) 80xxx

MH>As one Matt to another: MH> Do you happen to have any floodfill or polygon fill routines? Or even just MH> basic ideas. Just anything at all, mode X or otherwise. here is a generic, recusive fill algorythm in BASIC. ------------------------ FILL.BAS ----------------------- 'BASIC Example of an Area Fill 'Assumes: 'Pixel( x, y) a 2 dimensional array of Pixels ' The same as on the screen ' 'X1, Y1 Starting coordinates to fill at 'ReplaceColor The Color to fill the area with 'SearchColor The Color to be replaced (background) ' 'XpixStart The Smallest Legal X value for Pixel (X, Y) 'XpixEnd The Largest Legal X value for Pixel (X, Y) 'YpixStart The Smallest Legal Y value for Pixel (X, Y) 'YpixEnd The Largest Legal Y value for Pixel (X, Y) 'Main Sub.. Sets up the variables and then ' Recusrively calls FLOOD.FILL.AREA SUB FILL.AREA (X1,Y1,ReplaceColor) SearchColor = Pixel(X1, Y1) IF SearchColor = ReplaceColor THEN EXIT FUNCTION FLOOD.FILL.AREA (X1), (Y1), SearchColor, ReplaceColor END SUB 'This routine is recursive... 'Routine to do the dirty work of filling an area. 'Starts at point X1,Y1 'Fills As far as possible to the left, then to the right 'After that, it check each pixel above and below the 'line just created to see if it can fill there SUB FLOOD.FILL.AREA (Xpos, Ypos, SearchColor, ReplaceColor) 'Local Variables allocated on the stack: 'LeftX 'RightX 'N LeftX = Xpos RightX = Xpos Pixel(Xpos, Ypos) = ReplaceColor 'Scan (& Fill) Left DO WHILE (LeftX > XpixStart) IF Pixel(LeftX - 1, Ypos) = SearchColor THEN LeftX = LeftX - 1 Pixel(LeftX, Ypos) = ReplaceColor ELSE EXIT DO END IF LOOP 'Scan and Fill Right DO WHILE (RightX < XpixEnd) IF Pixel(RightX + 1, Ypos) = SearchColor THEN RightX = RightX + 1 Pixel(RightX, Ypos) = ReplaceColor ELSE EXIT DO END IF LOOP 'Check pixels above Line just created IF Ypos > YpixStart THEN FOR N = LeftX TO RightX IF Pixel(N, Ypos - 1) = SearchColor THEN FLOOD.FILL.AREA (N), (Ypos - 1), SearchColor, ReplaceColor END IF NEXT N END IF 'Check pixels below Line just created IF Ypos < YpixEnd THEN FOR N = LeftX TO RightX IF Pixel(N, Ypos + 1) = SearchColor THEN FLOOD.FILL.AREA (N), (Ypos + 1), SearchColor, ReplaceColor END IF NEXT N END IF END SUB --------------------------------------------------------------- The above should give you an idea as to the method. Start with a dot, expand left and right as far as possible, the check every dot above and below the line you just made to see if you can (recursively) do the whole thing again. Hope this helps. -Matt Pritchard === * SLMR 2.1a * Unable to locate Coffee -- Operator Halted! --- InterPCB 1.50 # Origin: CENTRAL BBS -Texas' BEST BBS! 214-393-7090 HST 3+GIGs (8:930/21) * Origin: Gateway System to/from RBBS-NET (RBBS-PC 1:10/8)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET