Post by tenochtitlanuk on Apr 10, 2020 15:42:40 GMT -5
There have been interesting posts recently here and on JB forim about these programming exercises.
Flood filling algorithms written in LB are very slow.
Fills using triangles filled line-at-a-time are better. But many polygon shapes cannot be created with triangles from one point ( think in r-theta terms. You need polycorners with steady increase in theta)
Seems a bit like trying to do something because it CAN be done, rather than is NEEDED to be done this way ( in JB)
Why don't we encourage people to sample the ( free trial) LB and the ease of using the flood fill GDI call?
Also the debate about ways to produce large BMPs. I seldom go above 1000x1000, and am very happy at that size. Above it I can go to near 1920x1080 on my screen.
For even larger resolution I can go the route of getting screen as a bmp and using graphic print OR the technique not recently mentioned of dividing large image into say 500x500 tiles and drawing each, then stitching the bmp files together programmatically.
Anyway, couldn't resist this fill-demo.. I see interesting colour contours round this scary beast! ( Runs at this speed in LB)
A real 'Easter Bunny'!
www.diga.me.uk/turtleDraw.html ..... www.diga.me.uk/floodFill2.html ..... www.diga.me.uk/ellipseFlowers.html may also be of interest.
You need a suitable black and white starter bmp, and may want to alter the target colour and the centre to fill from....
UpperLeftX = 1
UpperLeftY = 1
WindowWidth =400
WindowHeight =480
nomainwin
global hdc
open "Fill Stars" for graphics_nsb as #wg
#wg "trapclose [quit]"
hw =hwnd( #wg)
calldll #user32, "GetDC", hw as ulong, hdc as ulong
loadbmp "scr", "rabbit.bmp"
#wg "down ; drawbmp scr 0 0"
x =200
y =200
for i =1 to 50
scan
r =int( 40 +216 *rnd( 1))
g =int( 40 +216 *rnd( 1))
b =int( 40 +216 *rnd( 1))
fillCol$ =str$( r) +" " +str$( g); " " +str$( b)
#wg "backcolor "; fillCol$
targetcolor =0 ' this is the colour of the outline to fill out to.
calldll #gdi32, "ExtFloodFill",_
hdc as ulong,_
x as long,_
y as long,_
targetcolor as long,_
_FLOODFILLBORDER as long,_ ' ' ie fill out 'til this colour is met...
result as long
calldll #kernel32, "Sleep", 100 as long, ret as void
#wg "getbmp scr 0 0 400 480"
bmpsave "scr", "aniRabbit" +right$( "000" +str$( i), 3) +".bmp"
next i
wait
[quit]
calldll #user32, "ReleaseDC", hw as ulong, hdc as ulong, ret as void 'release the DC
close #wg
end