it would be nice if anyone of the PB pros could have a look at the following code, that I extracted from a bigger project where I try to mimic good old GFA fill patterns.
On Windows this generally works with a lot tested PB versions of ASM and C compiler.
PB 6.02 on MacOS crashes with ASM.
MacOS C-Backend PB 6.02, PB 6.04, PB 6.10 and PB 6.11 Beta 2 all give same wrong results of grey boxes instead of blue patterns, as if there is no filter.
And in my bigger project on MacOS the 2ddrawing engine simply seems to crash in the background, because the DrawText after some CustomFilters doesn't do anything.
Code: Select all
Structure str_fillpattern
Array fil.a(7,7)
EndStructure
DataSection
lbl_fillpattern:
Data.a 1,1,1,0,1,1,1,0
Data.a 1,1,0,1,1,1,0,1
Data.a 1,0,1,1,1,0,1,1
Data.a 0,1,1,1,0,1,1,1
Data.a 1,1,1,0,1,1,1,0
Data.a 1,1,0,1,1,1,0,1
Data.a 1,0,1,1,1,0,1,1
Data.a 0,1,1,1,0,1,1,1
Data.a 0,1,1,1,1,1,1,0
Data.a 1,0,1,1,1,1,0,1
Data.a 1,1,0,1,1,0,1,1
Data.a 1,1,1,0,0,1,1,1
Data.a 1,1,1,0,0,1,1,1
Data.a 1,1,0,1,1,0,1,1
Data.a 1,0,1,1,1,1,0,1
Data.a 0,1,1,1,1,1,1,0
EndDataSection
Restore lbl_fillpattern
Global Dim fillpattern.str_fillpattern(2)
For fy = 0 To 7
For fx = 0 To 7
Read.a fillpattern(1)\fil(fy,fx)
Next fx
Next fy
For fy = 0 To 7
For fx = 0 To 7
Read.a fillpattern(2)\fil(fy,fx)
Next fx
Next fy
Global *fillpointer.str_fillpattern
Global backcol.l = RGB(255,255,255)
Global frontcol.l = RGB(0,0,255)
Procedure FilterCallback(x, y, source.l, target.l)
mx = x % 8
my = y % 8
If *fillpointer\fil(my, mx) = 0
target = backcol
Else
target = frontcol ;Additional question: when commented out I would expect the blue color set at FillArea set as target.
EndIf
ProcedureReturn target
EndProcedure
If OpenWindow(0, 0, 0, 400, 200, "CustomFilter TEST", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
cid = CanvasGadget(#PB_Any, 0, 0, 400, 200)
If StartDrawing(CanvasOutput(cid))
Box(50,50,100,100,$0000ff)
Box(250,50,100,100,$000000)
DrawingMode(#PB_2DDrawing_CustomFilter)
CustomFilterCallback(@FilterCallback())
*fillpointer = @fillpattern(1)
FillArea(100, 100, $ffffff, frontcol)
*fillpointer = @fillpattern(2)
FillArea(300, 100, $ffffff, frontcol)
DrawingMode(#PB_2DDrawing_Default)
DrawText(100,180,"Hallo")
StopDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Additional question: Also I'm wondering why the blue color set at the FillArea seems to not be send to the filter callback as target color, and it is set as source color, from my point of view the naming of "source" and "target" in the example and docs is wrong.
Thanks, hoerbie