Page 1 of 1

VectorDrawing antialiasing + tansparancy

Posted: Thu Dec 21, 2023 10:44 am
by pf shadoko
several vectordrawing lib bugs have been present since the beginning.
tell me if you have the possibility to correct these bugs (probably inherent to TinySVG)
(if not, I wouldn't waste my time making reports, which have probably already been done).

the bug that bothers me most concerns anti-aliasing on transparency
below is a white circle (transparent image) on a white background

Code: Select all

OpenWindow(0, 0, 0, 800, 600, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(0,$FFFFFF)

CreateImage(0,200, 150,32,#PB_Image_Transparent )
StartVectorDrawing(ImageVectorOutput(0))
AddPathCircle(100,75,50):VectorSourceColor($FFFFFFFF):StrokePath(4)
StopVectorDrawing()
z=4
ResizeImage(0,200*z, 150*z,#PB_Image_Raw   )
ImageGadget(0, 0, 0, 800, 600, ImageID(0))

Repeat  
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
(concerning the source, antialiasing should only modify the aplha)

Re: VectorDrawing antialiasing + tansparancy

Posted: Thu Dec 21, 2023 11:15 am
by pjay
Isn't this a limitation of the ImageGadget / ButtonImageGadget rather than an issue with the vector library?

Try drawing on a canvas gadget.

Re: VectorDrawing antialiasing + tansparancy

Posted: Thu Dec 21, 2023 4:57 pm
by pf shadoko
the problem arises with transparent output
(canva is not transparent)

Re: VectorDrawing antialiasing + tansparancy

Posted: Thu Dec 21, 2023 5:27 pm
by STARGÅTE
The problem is, if you set #PB_Image_Transparent for the created image, the color channels are still black.
So the antiallising is performed between white and black.
You can draw transparent white color before starting the vector drawing.

Code: Select all

OpenWindow(0, 0, 0, 800, 600, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(0,$FFFFFF)

CreateImage(0,200, 150,32,#PB_Image_Transparent )
StartDrawing(ImageOutput(0))
	DrawingMode(#PB_2DDrawing_AllChannels)
	Box(0, 0, OutputWidth(), OutputHeight(), $00FFFFFF)
StopDrawing()
StartVectorDrawing(ImageVectorOutput(0))
AddPathCircle(100,75,50):VectorSourceColor($FFFFFFFF):StrokePath(4)
StopVectorDrawing()
z=4
ResizeImage(0,200*z, 150*z,#PB_Image_Raw   )
ImageGadget(0, 0, 0, 800, 600, ImageID(0))

Repeat  
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow

Re: VectorDrawing antialiasing + tansparancy

Posted: Thu Dec 21, 2023 6:12 pm
by pf shadoko
@ STARGÅTE
thanks for your method, it allows you to display white drawings :mrgreen:
but what if you want different colors?
in the following example, I put an RGB background image
I superimpose a transparent image containing 2 circles, one white and one black
(note: I use your method for my foliage textures, I use a transparent green background, but the edges of the branches are green too)

Code: Select all

OpenWindow(0, 0, 0, 800, 600, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(0,$FFFFFF)

CreateImage(0,200, 150,32,#PB_Image_Transparent )
CreateImage(1,800,600) ; back RGB
StartDrawing(ImageOutput(1))
	Box(266*0, 0, 266,600, $88)
	Box(266*1, 0, 266,600, $8800)
	Box(266*2, 0, 266,600, $880000)
StopDrawing()

StartDrawing(ImageOutput(0))
	DrawingMode(#PB_2DDrawing_AllChannels)
	Box(0, 0, OutputWidth(), OutputHeight(), $00FFFFFF)
StopDrawing()
StartVectorDrawing(ImageVectorOutput(0))
AddPathCircle(100,50,50):VectorSourceColor($FFFFFFFF):StrokePath(4)
AddPathCircle(100,100,50):VectorSourceColor($FF000000):StrokePath(4)
StopVectorDrawing()
z=4
ResizeImage(0,200*z, 150*z,#PB_Image_Raw   )

ImageGadget(1, 0, 0, 800, 600, ImageID(1))
ImageGadget(0, 0, 0, 800, 600, ImageID(0))

Repeat  
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow