
So i tried to code a routine that fills any object(s) / background(s) - Even objects where the outline uses more as only color instead the pure command require! (I found an article about this in an basic coding book from 1986 and tried to rewrite it for purebasic)
The trick is to check only for the backgroundcolor you want to fill (or replace)... just take a look to the bad code and you may realise how it would work...
Code: Select all
Procedure MyFill(x,y,lColorSrc.l,lColorDes.l)
If Point(x,y) = lColorDes
;
Else
If Point(x,y) = lColorSrc
;
If x > 0 And y > 0
Plot(x,y,lColorDes)
EndIf
;
; ---- Check nearest pixel ----
;
If Point (x-1, y ) = lColorSrc : MyFill (x-1, y , lColorSrc, lColorDes) : EndIf
If Point (x+1, y ) = lColorSrc : MyFill (x+1, y , lColorSrc, lColorDes) : EndIf
; If Point (x , y-1) = lColorSrc : MyFill (x , y-1, lColorSrc, lColorDes) : EndIf
If Point (x , y+1) = lColorSrc : MyFill (x , y+1, lColorSrc, lColorDes) : EndIf
EndIf
EndIf
EndProcedure
Edit: You have to call StartDrawing() before calling MyFill() procedure and call StopDrawing() after MyFill!