home *** CD-ROM | disk | FTP | other *** search
- /*********************
- *
- * gr_fill.c - Graphics general pupose fill.
- *
- * Purpose: This file contains the graphics boundary fill function
- * and its supporting functions.
- *
- * Blackstar C Function Library
- * (c) Copyright 1985,1989 Sterling Castle Software
- *
- *******/
-
- #include "blackstr.h"
- #include "gr_head.h"
-
- extern gr_gpt_(int x, int y);
-
-
- /********
- *
- * gr_fill(seedx,seedy) - general boundary fill function
- *
- **/
-
- void gr_fill(int seedx, int seedy)
- {
- int x1,x2;
-
- ut_push(-1); ut_push(-1); /* save end on stack */
- while(seedx != -1) {
- x1 = gr_fnb(seedx,seedy) + 1;
- x2 = gr_fpb(seedx,seedy) - 1;
- gr_line(x1,seedy,x2 ,seedy);
- gr_fseed(x1,x2,seedy); /* find more seeds */
- seedy = ut_pop(); /* get next seed */
- seedx = ut_pop();
- }
- }
-
-
- /********
- *
- * gr_fseed(x1,x2,y1) - find new seed point
- *
- **/
-
- void gr_fseed(int x1, int x2, int y1)
- {
- int x,y;
-
- for(y=y1-1; y<y1+2; y+=2) {
- x = x2;
- while(x >=x1) { /* while not interior bound */
- if(gr_gpt_(x,y)!=grfcol_) { /* start of run */
- ut_push(x); /* save point on stack */
- ut_push(y);
- x = gr_fnb(x,y); /* go to left boundary */
- } else
- --x; /* still in boundary */
- }
- }
- }
-
-
- /********
- *
- * gr_fnb(x,y) - find negative boundary
- *
- **/
-
- int gr_fnb(int x, int y)
- {
- while((gr_gpt_(x,y) != grfcol_) && (x > gr_minx_))
- --x;
- return(x);
- }
-
-
- /********
- *
- * gr_fpb(x,y) - find positive boundary
- *
- **/
-
- int gr_fpb(int x, int y)
- {
- while((gr_gpt_(x,y) != grfcol_) && (x < gr_maxx_))
- ++x;
- return(x);
- }
-
-