|
Post by roberto on Mar 28, 2021 17:00:09 GMT -5
Dear LB-friends,
Programming shapes with black lines on a white background and filling those shapes with any color with floodfill works fine. But what and where to change in the "floodfil-subs and floodfill-functions" to create shapes with white lines on a black background filling them with any color. So how to change "_floodfillborder" from black to white or any other color. I know it can be done, but I can not find it.
|
|
|
Post by Brandon Parker on Mar 28, 2021 19:59:45 GMT -5
Do you have code that you are working with that you can share?
{:0)
Brandon Parker
|
|
|
Post by Rod on Mar 29, 2021 2:18:10 GMT -5
This is the LBPE there are two colours used the surface to paint and the surround. They are just long color values. Have a read and ask again if you still need help. alycesrestaurant.com/lbpe/FloodFill.html
|
|
|
Post by roberto on Mar 29, 2021 2:22:50 GMT -5
I send you the working white one (first listing) and the baulking black one (second listing).
nomainwin
WindowWidth = 400 WindowHeight = 600 UpperLeftX = int((DisplayWidth-WindowWidth)/2)-200 UpperLeftY = int((DisplayHeight-WindowHeight)/2)
graphicbox #w1.g1 000,000,400,600
open "black border box" for graphics_nsb as #w1 #w1 "trapclose [quit]"
#w1.g1 "down" #w1.g1 "flush" #w1.g1 "when leftButtonDown [ff1]"
#w1.g1 "fill 255 255 255" #w1.g1 "color 000 000 000" #w1.g1 "size 3" #w1.g1 "line 100 100 300 100" #w1.g1 "line 300 100 300 300" #w1.g1 "line 300 300 100 300" #w1.g1 "line 100 300 100 100"
wFillType = _FLOODFILLBORDER print wFillType global ExtFoodFill
fillCol$ = str$(250)+" "+str$(150);" "+str$(050)
hw = hwnd( #w1.g1) hdc = GetDC(hw) x = 150 y = 150
#w1.g1 "backcolor ";fillCol$ wFillType =_FLOODFILLBORDER print wFillType
wait
'---------------------------------------
[ff1] rob = ExtFloodFill(hdc,x,y,Color) print ExtFoodFill
wait
'---------------------------------------
[quit] RelMemori = ReleaseDC(hw,hdc) close #w1 : end end
'---------------------------------------
function ExtFloodFill(hdc,x,y,Color) wFillType =_FLOODFILLBORDER Color = 0 calldll #gdi32,"ExtFloodFill",_ hdc as Ulong,_ x as long,_ y as long,_ Color as long,_ wFillType as long,_ ExtFoodFill as long end function
function GetDC(handle) calldll #user32, "GetDC", _ handle as Ulong, _ GetDC as Ulong end function
function ReleaseDC(handle, hDC) calldll #user32, "ReleaseDC", _ handle as Ulong, _ hDC as Ulong, _ ReleaseDC as Long end function
function FloodFill( hwinDC, x, y) wFillType = _FLOODFILLBORDER crColor = bg calldll #gdi32, "ExtFloodFill",_ hwinDC as ulong,_ x as Long,_ y as Long,_ crColor as Long,_ wFillType as long,_ FloodFill as long end function
'---------------------------------------
nomainwin
WindowWidth = 400 WindowHeight = 600 UpperLeftX = int((DisplayWidth-WindowWidth)/2)+200 UpperLeftY = int((DisplayHeight-WindowHeight)/2)
graphicbox #w2.g2 000,000,400,600
open "white border box" for graphics_nsb as #w2 #w2 "trapclose [quit]"
#w2.g2 "down" #w2.g2 "flush" #w2.g2 "when leftButtonDown [ff2]"
#w2.g2 "fill 000 000 000" #w2.g2 "color 255 255 255" #w2.g2 "size 3" #w2.g2 "line 100 100 300 100" #w2.g2 "line 300 100 300 300" #w2.g2 "line 300 300 100 300" #w2.g2 "line 100 300 100 100"
wFillType = _FLOODFILLBORDER print wFillType global ExtFoodFill
fillCol$ = str$(050)+" "+str$(150);" "+str$(250)
hw = hwnd( #w2.g2) hdc = GetDC(hw) x = 150 y = 050
#w2.g2 "backcolor ";fillCol$ wFillType =_FLOODFILLBORDER print wFillType
'---------------------------------------
wait
'---------------------------------------
[ff2] rob = ExtFloodFill(hdc,x,y,Color) print ExtFoodFill
wait
'---------------------------------------
[quit] RelMemori = ReleaseDC(hw,hdc) close #w2 : end end
'---------------------------------------
function ExtFloodFill(hdc,x,y,Color) wFillType =_FLOODFILLBORDER Color = 0 calldll #gdi32,"ExtFloodFill",_ hdc as Ulong,_ x as long,_ y as long,_ Color as long,_ wFillType as long,_ ExtFoodFill as long end function
function GetDC(handle) calldll #user32, "GetDC", _ handle as Ulong, _ GetDC as Ulong end function
function ReleaseDC(handle, hDC) calldll #user32, "ReleaseDC", _ handle as Ulong, _ hDC as Ulong, _ ReleaseDC as Long end function
function FloodFill( hwinDC, x, y) wFillType = _FLOODFILLBORDER crColor = bg calldll #gdi32, "ExtFloodFill",_ hwinDC as ulong,_ x as Long,_ y as Long,_ crColor as Long,_ wFillType as long,_ FloodFill as long end function
'---------------------------------------
|
|
|
Post by tenochtitlanuk on Mar 29, 2021 3:41:57 GMT -5
|
|
|
Post by Rod on Mar 29, 2021 5:02:31 GMT -5
You are setting the color to black. But you are using floodfillborder, it should be white. The border color is white, so you are filling from within the square to the border. So you also need to start inside the square.
x=150 y=150
function ExtFloodFill(hdc,x,y,Color) wFillType =_FLOODFILLBORDER Color = 255+255*256+255*256*256 calldll #gdi32,"ExtFloodFill",_ hdc as Ulong,_ x as long,_ y as long,_ Color as long,_ wFillType as long,_ ExtFoodFill as long end function
|
|
|
Post by Rod on Mar 29, 2021 5:05:57 GMT -5
I don't know why you set a global extfloodfill, it is not required, neither the wfilltype which is all handled in the function.
|
|