Page 1 of 1

StartDrawing() and StartVectorDrawing()

Posted: Mon May 06, 2024 12:53 pm
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

Re: StopDrawing() and StartVectorDrawing()

Posted: Mon May 06, 2024 1:09 pm
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.

Re: StopDrawing() and StartVectorDrawing()

Posted: Mon May 06, 2024 1:10 pm
by jacdelad
Even if you could nest it, wouldn't that cause serious problems? Especially when working with threads.

Re: StopDrawing() and StartVectorDrawing()

Posted: Mon May 06, 2024 9:18 pm
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