So i'm migrating a project from PB 4.60 to PB 5.40 LTS and i've found that DisplayRGBFilter() has been removed.
I read in the history...
Code: Select all
Removed: DisplayRGBFilter() -> can be replaced with a zoomed sprite with color
Cheers,
Hip
Code: Select all
Removed: DisplayRGBFilter() -> can be replaced with a zoomed sprite with color
Code: Select all
Procedure DisplayRGBFilter(x.i, y.i, Width.i, Height.i, R.i, G.i, B.i)
Static RGBSprite.i = -1
Static OldWidth.i, OldHeight.i, OldColor.i = -1
Protected Color.i
Color = RGB(R, G, B)
If Not IsSprite(RGBSprite)
RGBSprite = CreateSprite(#PB_Any, 1, 1, #PB_Sprite_AlphaBlending)
EndIf
If OldColor <> Color
If StartDrawing(SpriteOutput(RGBSprite))
Plot(0, 0, Color)
StopDrawing()
EndIf
OldColor = Color
EndIf
If OldWidth <> Width Or OldHeight <> Height
ZoomSprite(RGBSprite, Width, Height)
OldWidth = Width
OldHeight = Height
EndIf
DisplayTransparentSprite(RGBSprite, x, y, 128)
EndProcedure
If InitSprite() = 0
MessageRequester("Error", "Can't open screen & sprite environment!", 0)
End
EndIf
If OpenWindow(0, 0, 0, 320, 200, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0, 320, 200)
CreateSprite(0, 50, 50) ; Erstellt ein leeres Sprites, dies wird komplett schwarz sein
Repeat
Repeat
Event = WindowEvent()
If Event = #PB_Event_CloseWindow
End
EndIf
Until Event = 0
FlipBuffers()
ClearScreen(RGB(0, 0, 200)) ; Ein blauer Hintergrund
DisplaySprite(0, 10, 10) ; Darstellung unserer schwarzen Box in der linken oberen Ecke
DisplaySprite(0, 260, 10) ; Darstellung unserer schwarzen Box in der rechten oberen Ecke
DisplayRGBFilter(15, 15, 10 + i, 100, 0, 128, 128)
i + 1
If i = 280
i = 0
EndIf
ForEver
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
EndIf
EndIf
You don't have to redraw the sprite when it's color changes. Its color is determined by an additional parameter.infratec wrote:If you use it more often in one program, maybe a list or a map of the areas is needed to avoid
all time StartDrawing()
Code: Select all
Procedure DisplayRGBFilter(x.i, y.i, Width.i, Height.i, R.i, G.i, B.i)
Static RGBSprite.i = 0
; Static OldWidth.i, OldHeight.i
Protected Color.i = RGB(R, G, B)
If Not RGBSprite
RGBSprite = CreateSprite(#PB_Any, 1, 1, #PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(RGBSprite))
Plot(0, 0, RGB(255, 255, 255))
StopDrawing()
EndIf
EndIf
; If OldWidth <> Width Or OldHeight <> Height
ZoomSprite(RGBSprite, Width, Height)
; OldWidth = Width
; OldHeight = Height
; EndIf
DisplayTransparentSprite(RGBSprite, x, y, 128, Color)
EndProcedure