Post by tenochtitlanuk on Jun 27, 2018 15:32:13 GMT -5
Here's a demo of the two- it either fills out to chosen boundary colour, over all other colours OR fills out for as long as it is on the chosen colour.
nomainwin
UpperLeftX = 10
UpperLeftY = 10
WindowWidth =530
WindowHeight =540
prompt "Enter 0 ( surface) or 1 ( border)"; response$
if not ( instr( "10", response$)) then end
type = val( response$) ' 0 for boundary, 1 for surface <<<<<<<<<<<<<<<< Change to try each fill type.. <<<
open "Fill-er-upper" for graphics_nsb as #wg
#wg "trapclose quit"
hw =hwnd( #wg) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
calldll #user32, "GetDC", hw as ulong, hdc as ulong ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#wg "down"
for i =1 to 50
r =int( 192 +64 *rnd( 1))
g =int( 192 +64 *rnd( 1))
b =int( 192 +64 *rnd( 1))
fillCol$ =str$( r) +" " +str$( g); " " +str$( b)
#wg "up ; goto "; int( 500 *rnd( 1)); " "; int( 500 *rnd( 1)); " "; int( 500 *rnd( 1))
#wg "color "; fillCol$
#wg "backcolor "; fillCol$
#wg "down ; circlefilled "; int( 50 +150 *rnd( 1))
next i
#wg "up ; goto 250 180 ; down ; color 0 0 120 ; circle 120 ; up"
x =250
y =250
calldll #gdi32, "GetPixel", hdc as ulong, x as long, y as long, pixcol as ulong
bl = int( pixcol /( 256*256))
gr = int( (pixcol -bl *256*256) / 256)
re = int( pixcol -bl *256*256 -gr *256)
c$ =str$( re); " "; str$( gr); " "; str$( bl)
#wg "color red"
#wg "backcolor red"
notice "Watch the fill and where it goes out to.. it will fill red out from centre to the original" +_
" colour boundary, or to the circle outline, depending on your choice of 0 or 1. Run several times." +_
" NB this program fills FROM the centre ( 250, 250)"
x =250
y =250
if type =1 then
targetcolor =120 *2^16 ' This is 120/256 blue. Colour = blue*2^16 +green *2^8 +red.
calldll #gdi32, "ExtFloodFill",_
hdc as ulong,_
x as long,_
y as long,_
targetcolor as long,_
_FLOODFILLBORDER_ as long,_
result as long ' ie floodfill out until this targetcolor is met... <<<<<<<<<<<<<<<<<<<<<<<<<<
else
targetcolor =pixcol ' this is the border colour to be replaced up-to. Works OK.
calldll #gdi32, "ExtFloodFill",_
hdc as ulong,_
x as long,_
y as long,_
targetcolor as long,_
_FLOODFILLSURFACE_ as long,_
result as long 'floodfill out wherever this colour is met... <<<<<<<<<<<<<<<<<<<<<<<<<<
end if
'calldll #kernel32, "Sleep", 100 as long, ret as void' delay not needed here
scan
wait
sub quit h$
calldll #user32, "ReleaseDC", hw as ulong, hdc as ulong, ret as void 'release the DC <<<<<<<<<<<<<<<<<<<<<
close #wg
end
end sub