How can vector drawing be used with alpha channels?
Posted: Fri Sep 27, 2019 9:02 pm
I'm trying to draw an image which has a transparent background using the vector library.
I created an image with #PB_Image_Transparent and made a circle. But the anti-aliasing appears to have black in it? I tried to work around this by drawing a vector image onto the alpha channel using DrawImage() but this didn't work either. It seems like the only way to draw to the alpha channel is to do so with raster commands.
Can anyone confirm this problem or am I using the library incorrectly?
I created an image with #PB_Image_Transparent and made a circle. But the anti-aliasing appears to have black in it? I tried to work around this by drawing a vector image onto the alpha channel using DrawImage() but this didn't work either. It seems like the only way to draw to the alpha channel is to do so with raster commands.
Can anyone confirm this problem or am I using the library incorrectly?
Code: Select all
OpenWindow(#PB_Any,10,10,320,240,"Vector on transparent")
Image=CreateImage(#PB_Any,320,240,32,#PB_Image_Transparent)
StartVectorDrawing(ImageVectorOutput(Image))
VectorSourceColor(RGBA(255,0,0,255))
AddPathCircle(120,120,120)
ClosePath()
StrokePath(30)
StopVectorDrawing()
ImageGadget(#PB_Any,0,0,32,32,ImageID(Image))
;##
OpenWindow(#PB_Any,10,290,320,240,"Raster draw onto alpha channel")
Image=CreateImage(#PB_Any,320,240,32)
StartDrawing(ImageOutput(Image))
Box(0,0,320,240,#Red)
DrawingMode(#PB_2DDrawing_AlphaChannel)
Circle(120,120,120,RGBA(0,0,0,0))
StopDrawing()
ImageGadget(#PB_Any,0,0,32,32,ImageID(Image))
;##
OpenWindow(#PB_Any,10,570,320,240,"DrawImage() onto alpha channel")
Mask=CreateImage(#PB_Any,320,240,32,#Black)
StartVectorDrawing(ImageVectorOutput(Mask))
VectorSourceColor(RGBA(255,255,255,255))
AddPathCircle(120,120,120)
ClosePath()
StrokePath(30)
StopVectorDrawing()
Image=CreateImage(#PB_Any,320,240,32)
StartDrawing(ImageOutput(Image))
Box(0,0,320,240,#Red)
DrawingMode(#PB_2DDrawing_AlphaChannel)
DrawImage(ImageID(Mask),0,0)
StopDrawing()
ImageGadget(#PB_Any,0,0,32,32,ImageID(Image))
Repeat
Until WaitWindowEvent(1)=#PB_Event_CloseWindow