[68k] Flood Fill (1/1) blue_bear_94: I was trying to implement flood filling with the right-hand algorithm (http://en.wikipedia.org/wiki/Flood_fill#Fixed_memory_method_.28right-hand_fill_method.29), but it don't seem to work. Here's the code specific to the flood filling:Code: Select All | Copy To Clipboard123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199typedef struct { int x,y,dir;} pt;enum {LEFT,UP,RIGHT,DOWN};#define DEF_DIR DOWN#define PT_NULL (pt){-20,-20,0}#define pteq(pt1,pt2) (pt1.x==pt2.x)&&(pt1.y==pt2.y)&&(pt1.dir==pt2.dir)#define pteqc(pt1,pt2) (pt1.x==pt2.x)&&(pt1.y==pt2.y)#define ptcolor(Pt) (Pt.x>=0&&Pt.xxy.x1&&Pt.y>=0&&Pt.yxy.y1)?GetGPix(Pt.x,Pt.y):mf#define nextdir(Dir) (Dir+1)%4#define prevdir(Dir) (Dir+3)%4#define oppdir(Dir) (Dir+2)%4int mf=3;void FillPt(pt Pt,int col){ int w=whole_scn->xy.x1; int h=whole_scn->xy.y1; if (Pt.x>=0&&Pt.x=0&&Pt.y=0&&Pt.xxy.x1&&Pt.y>=0&&Pt.yxy.y1)?GetGPix(Pt.x,Pt.y):mf#define nextdir(Dir) (Dir+1)%4#define prevdir(Dir) (Dir+3)%4#define oppdir(Dir) (Dir+2)%4int mf=3;void FillPt(pt Pt,int col){ int w=whole_scn->xy.x1; int h=whole_scn->xy.y1; if (Pt.x>=0&&Pt.x=0&&Pt.yOK>Fill).Edit: Binary.Edit 2: Here is documentation for GetGPix and DrawGPix.GetGPix(int x, int y) returns the color of the pixel at the point (x,y). 0 is white, and 3 is black.SetGPix(int x, int y, int color, int attr) draws a pixel at the point (x,y) using the color specified. The attr argument means:GA_DRAW: Replaces the color.GA_ROTATE: Rotates the color.GA_FLIP: Inverts. The color is disregarded in this drawing mode. blue_bear_94: I came up with an alternate solution which is easier and still works on the TI-89 without running out of memory (on a 64x64, at least):[attached]Now if only I can figure out why the keyboard input sometimes screws up while using the pencil tool and can't be fixed even with a RAM clear... I think it has to do with not putting enough delay between the ticks.(edit: yet another bug, reattaching)(yet another edit: flood fill works even for an image the size of the TI-89 screen!) Navigation  Message Index