Waiting Screen with transparent background
Posted: Mon Feb 05, 2024 4:35 pm
Hi,
I would like to make an animated waiting screen with transparent background with 2D drawing functions.
Here is what I was able to achieve :
As you can see, the transparency also apply to my drawing.
What should I change to apply fully opaque draws ?
Thanks for your time.
EDIT : Code updated
I would like to make an animated waiting screen with transparent background with 2D drawing functions.
Here is what I was able to achieve :
Code: Select all
Procedure Rotate(*oldPos.Point, *RotationCenter.Point, angle.f, *newPos.Point)
Protected xM, yM
angle = angle * #PI / 180
xM = *oldPos\x - *RotationCenter\x
yM = *oldPos\y - *RotationCenter\y
*newPos\x = Round(xM * Cos(angle) + yM * Sin(angle) + *RotationCenter\x, #PB_Round_Nearest)
*newPos\y = Round(- xM * Sin(angle) + yM * Cos(angle) + *RotationCenter\y, #PB_Round_Nearest)
EndProcedure
If OpenWindow(0, 0, 0, 200, 200, "", #PB_Window_BorderLess|#PB_Window_ScreenCentered)
SetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE, GetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE)|#WS_EX_LAYERED);|#WS_EX_TOOLWINDOW)
Define RotationCenter.Point : RotationCenter\x = 100 : RotationCenter\y = 100
Define startingPos.Point : startingPos\x = 180 : startingPos\y = 100
Define angle.f = 0
Define newpos_red.Point, newpos_green.Point
CreateImage(0, 200, 200, 32, #PB_Image_Transparent)
Define sz.SIZE
sz\cx = ImageWidth(0)
sz\cy = ImageHeight(0)
Define BlendMode.BLENDFUNCTION
BlendMode\SourceConstantAlpha = 255
BlendMode\AlphaFormat = #ULW_COLORKEY
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Transparent)
For i = 1 To 8
Rotate(startingPos, RotationCenter, angle, newpos_red)
Circle(newpos_red\x, newpos_red\y, 10, RGBA(255, 0, 0, 255))
If angle = 315
angle = 0
Else
angle = angle + 45
EndIf
Next
StopDrawing()
Repeat
event = WindowEvent()
hDC = StartDrawing(ImageOutput(0))
If hDC
DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Transparent)
Rotate(startingPos, RotationCenter, angle, newpos_red)
Circle(newpos_red\x, newpos_red\y, 10, RGBA(255, 0, 0, 255))
If angle = 315
angle = 0
Else
angle = angle + 45
EndIf
Rotate(startingPos, RotationCenter, angle, newpos_green)
Circle(newpos_green\x, newpos_green\y, 10, RGBA(0, 255, 0, 255))
UpdateLayeredWindow_(WindowID(0), 0, 0, @sz, hDC, @pptSrc.POINT, 0, @BlendMode, 2)
StopDrawing()
EndIf
Delay(200)
Until event = #PB_Event_CloseWindow
EndIf
What should I change to apply fully opaque draws ?
Thanks for your time.
EDIT : Code updated