tcat wrote:I am further thinking about fill. I do scan line fill for circle, and ellipse using BLOCK, that I now have optimised. Filled rectangle really is BLOCK on its own...
Funnily enough, Ive also been thinking about FILL recently, not least because the built-in fill doesnt work for larger screen resolutions. Anything above 1280x768 (Im sure someone can come up with the exact figure) just crashes the system. I havent got as far as thinking about algorithms, so just for the hell of it I decided to try out the one you posted here:
Code: Select all
100 COLOUR_NATIVE
110 ch = 1: CLS#ch
120 paper% = RPIX%(#ch; 1, 1)
130 CIRCLE#ch; 50, 50, 20
140 Fills#ch; paper%, 999, 100, 100
150 :
160 DEFine PROCedure Fills(chn, tgc%, rpc%, x%, y%)
170 REMark tgc%, rpc% - target, replacement colour
180 :
190 REMark PAUSE 1: rem Un-Remark to see the action
200 IF tgc% = RPIX%(#chn; x%, y%) THEN
210 REMark RPIX% = pick colour at x,y coord
220 BLOCK#chn; 1, 1, x%, y%, rpc% : REMark no clip
230 Fills#chn; tgc%, rpc%, x%, y% - 1 : REMark south
240 Fills#chn; tgc%, rpc%, x%, y% + 1 : REMark north
250 Fills#chn; tgc%, rpc%, x% - 1, y% : REMark west
260 Fills#chn; tgc%, rpc%, x% + 1, y% : REMark east
270 END IF
280 END DEFine Fills
290 :
300 :
310 REMark PROCEDURE Fill*(tgc, rpc, x, y: INTEGER);
320 REMark VAR c: INTEGER; (*tgc, rpc - target, replacement colour*)
330 REMark BEGIN
340 REMark (*c = pick colour at x,y coord *)
350 REMark IF c = tgc THEN
360 REMark Display.Dot(rpc, x, y, Display.replace); (*no clip*)
370 REMark Fill(tgc, rpc, x, y-1); (*south*)
380 REMark Fill(tgc, rpc, x, y+1); (*north*)
390 REMark Fill(tgc, rpc, x-1, y); (*west*)
400 REMark Fill(tgc, rpc, x+1, y); (*east*)
410 REMark END
420 REMark END Fill;
430 :
(This version is for GD2 systems only, and needs my Knoware/toolkits/RPIX% command.)
Sadly, it doesnt do very well, as it eats up stack space, and spends half its time back tracking. It wont do shapes much larger than the circle demonstrated here before crashing out. What else is there?