It is currently Sat Jul 20, 2019 7:01 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [Done] AddPathSegments - SVG Tiny standard
PostPosted: Sun Mar 25, 2018 9:57 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1205
Location: Germany, Glienicke
Hi, the documentation says:
"[...] command also accepts path descriptions in the format defined by the SVG Tiny standard [...]"

But, some paths are buggy:

"If a 'moveto' is followed by multiple pairs of coordinates, the subsequent pairs shall be treated as implicit 'lineto' commands."
This works for absolute coordinates, but not for relative:
Code:
Enumeration
   #Window
   #Gadget
EndEnumeration


OpenWindow(#Window, 0, 0, 800, 450, "Vector Canvas Gadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CanvasGadget(#Gadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window), #PB_Canvas_Keyboard)

If StartVectorDrawing(CanvasVectorOutput(#Gadget))
   
   VectorSourceColor($FF008000)
   AddPathSegments("M 50,50 250,50 250,250 50,250")
   StrokePath(10)
   
   VectorSourceColor($FF000080)
   AddPathSegments("m 50,50 200,0 0,200 -200,0")
   StrokePath(10)
   
   StopVectorDrawing()
EndIf

Repeat
   
   Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
         Break
      
   EndSelect
   
ForEver


Same problem, with the lineto statement:
"If more than one coordinate pair is specified, a polyline shall be drawn."
Code:
Enumeration
   #Window
   #Gadget
EndEnumeration


OpenWindow(#Window, 0, 0, 800, 450, "Vector Canvas Gadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CanvasGadget(#Gadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window), #PB_Canvas_Keyboard)

If StartVectorDrawing(CanvasVectorOutput(#Gadget))
   
   VectorSourceColor($FF008000)
   AddPathSegments("M 50,50 L 250,50 250,250 50,250")
   StrokePath(10)
   
   VectorSourceColor($FF000080)
   AddPathSegments("M 50,50 l 200,0 0,200 -200,0")
   StrokePath(10)
   
   StopVectorDrawing()
EndIf

Repeat
   
   Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
         Break
      
   EndSelect
   
ForEver

_________________
ImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: AddPathSegments - SVG Tiny standard
PostPosted: Wed Dec 26, 2018 10:05 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1205
Location: Germany, Glienicke
There is another mistake with the combination of "m" afther "z":

The relative moveto (m) statement shoud be relative to the last position, in case of "closed path"-statement (z) the coordinates of the connected point (as same as if I whould add a lineto statement to this point). Instead, the followed "m" statement is relative to an other position (the last M-defined position?).
These three paths (green: absolute, yellow: relative with lineto, red with close path) should overlap each other, but red is buggy.
Code:
Enumeration
   #Window
   #Gadget
EndEnumeration


OpenWindow(#Window, 0, 0, 800, 600, "Vector Canvas Gadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CanvasGadget(#Gadget, 0, 0, WindowWidth(#Window), WindowHeight(#Window), #PB_Canvas_Keyboard)

If StartVectorDrawing(CanvasVectorOutput(#Gadget))
   
   VectorSourceColor($FF008000)
   AddPathSegments("M 50,50 L 150,50 150,150 50,150 Z M 250,50 L 350,50 350,150 250,150 Z M 650,50 L 750,50 750,150 650,150 Z")
   StrokePath(15)
   
   VectorSourceColor($FF00C0FF)
   AddPathSegments("m 50,50 l 100,0 l 0,100 l -100,0 l 0,-100 m 200,0 l 100,0 l 0,100 l -100,0 l 0,-100 m 400,0 l 100,0 l 0,100 l -100,0 l 0,-100")
   StrokePath(10)                                                                                     ; ^ this is correct
   
   VectorSourceColor($FF0000FF)
   AddPathSegments("m 50,50 l 100,0 l 0,100 l -100,0 z m 200,0 l 100,0 l 0,100 l -100,0 z m 400,0 l 100,0 l 0,100 l -100,0 z")
   StrokePath(6)                                                                        ; ^ should be relative to the last position of "z"
   
   StopVectorDrawing()
EndIf

Repeat
   
   Select WaitWindowEvent()
     
      Case #PB_Event_CloseWindow
         Break
     
   EndSelect
   
ForEver


PB 5.70b4, x64, Win 7

_________________
ImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: AddPathSegments - SVG Tiny standard
PostPosted: Sun Mar 10, 2019 12:35 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5777
Location: Germany
fixed.

_________________
quidquid Latine dictum sit altum videtur


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye