StartDrawing() and StartVectorDrawing()

Just starting out? Need help? Post your questions and find answers here.
mestnyi
Addict
Addict
Posts: 1102
Joined: Mon Nov 25, 2013 6:41 am

StartDrawing() and StartVectorDrawing()

Post by mestnyi »

Code: Select all

If OpenWindow(0, 0, 0, 220, 220, " this good", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 10, 10, 200, 200)
  
  If StartVectorDrawing(CanvasVectorOutput(0))
    MovePathCursor(40, 60)
    AddPathArc(100, 140, 160, 20, 20)
    AddPathArc(160, 20, 220, 180, 20)
    AddPathArc(220, 180, 280, 80, 20)
    AddPathArc(280, 80, 340, 120, 20)
    AddPathLine(340, 120)
    
    VectorSourceColor(RGBA(255, 0, 0, 255))
    StrokePath(10)
    
    If StartDrawing(CanvasOutput(0))
      DrawingMode(#PB_2DDrawing_Default)
      Box(0, 0, 50, 20, $FFFFFF)
      Box(50, 0, 50, 20, $000000)
      
      DrawingMode(#PB_2DDrawing_Outlined)
      Box(0, 0, 100, 20, RGB(Random(255), Random(255), Random(255)))
      
      StopDrawing()
    EndIf
    
    StopVectorDrawing()
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
windows this not work why?

Code: Select all

If OpenWindow(0, 0, 0, 220, 220, "this not good", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 10, 10, 200, 200)
  
  If StartDrawing(CanvasOutput(0))
    DrawingMode(#PB_2DDrawing_Default)
    Box(0, 0, 50, 20, $FFFFFF)
    Box(50, 0, 50, 20, $000000)
    
    DrawingMode(#PB_2DDrawing_Outlined)
    Box(0, 0, 100, 20, RGB(Random(255), Random(255), Random(255)))
    
    If StartVectorDrawing(CanvasVectorOutput(0))
      MovePathCursor(40, 60)
      AddPathArc(100, 140, 160, 20, 20)
      AddPathArc(160, 20, 220, 180, 20)
      AddPathArc(220, 180, 280, 80, 20)
      AddPathArc(280, 80, 340, 120, 20)
      AddPathLine(340, 120)
      
      VectorSourceColor(RGBA(255, 0, 0, 255))
      StrokePath(10)
      
      StopVectorDrawing()
    EndIf
    
    StopDrawing()
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Last edited by mestnyi on Wed May 08, 2024 6:13 am, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: StopDrawing() and StartVectorDrawing()

Post by infratec »

I think it is not allowed to nest Start..Drawing()

The only official way is to use a seperate thread (as written in the help)
But not to the same output.
Last edited by infratec on Mon May 06, 2024 1:12 pm, edited 1 time in total.
User avatar
jacdelad
Addict
Addict
Posts: 2032
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: StopDrawing() and StartVectorDrawing()

Post by jacdelad »

Even if you could nest it, wouldn't that cause serious problems? Especially when working with threads.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
mestnyi
Addict
Addict
Posts: 1102
Joined: Mon Nov 25, 2013 6:41 am

Re: StopDrawing() and StartVectorDrawing()

Post by mestnyi »

what I know is that my first example works the same on Windows and MacOS.
my second example works on Mac OS and doesn't work on Windows
Post Reply