VectorDrawing antialiasing + tansparancy

Post bugreports for the Windows version here
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 386
Joined: Thu Jul 09, 2015 9:07 am

VectorDrawing antialiasing + tansparancy

Post 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)
pjay
Enthusiast
Enthusiast
Posts: 251
Joined: Thu Mar 30, 2006 11:14 am

Re: VectorDrawing antialiasing + tansparancy

Post 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.
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 386
Joined: Thu Jul 09, 2015 9:07 am

Re: VectorDrawing antialiasing + tansparancy

Post by pf shadoko »

the problem arises with transparent output
(canva is not transparent)
User avatar
STARGÅTE
Addict
Addict
Posts: 2228
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: VectorDrawing antialiasing + tansparancy

Post 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
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 386
Joined: Thu Jul 09, 2015 9:07 am

Re: VectorDrawing antialiasing + tansparancy

Post 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
Post Reply