Page 1 of 1

RotateCoordinates

Posted: Thu Sep 19, 2019 12:22 pm
by User_Russian
It is necessary that the numbers are next to the lines, but this does not happen. What am I doing wrong?

Code: Select all

If OpenWindow(0, 0, 0, 400, 400, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 400, 400)
  
  If StartVectorDrawing(CanvasVectorOutput(0))
    
    w = VectorOutputWidth()
    h = VectorOutputHeight()
    
    VectorFont(LoadFont(0, "Arial", 16))
    
    VectorSourceColor(RGBA(0, 0, 0, 255))
    
    RotateCoordinates(w/2, h/2, 40)
    For i=40 To 320 Step 40
      MovePathCursor(w/2, h-10)
      AddPathLine(w/2, h-20)
      
      SaveVectorState()
      MovePathCursor(w/2, h-40)
      RotateCoordinates(w/2, h/2, 360-i)
      DrawVectorText(Str(i/40-1))
      RestoreVectorState()
      
      StrokePath(1)
      RotateCoordinates(w/2, h/2, 40)
    Next
            
    StopVectorDrawing()
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

Re: RotateCoordinates

Posted: Thu Sep 19, 2019 1:08 pm
by Erlend
I do not have PB available here/right now so I'm not sure, but are you not drawing line and numbers on the same "diameter" only
moved slightly in y direction?

I think you need to draw number and lines on two seperate diameters..

Just my two cents...

Regards
Erlend

Re: RotateCoordinates

Posted: Thu Sep 19, 2019 1:46 pm
by #NULL
Maybe like this?

Code: Select all

      SaveVectorState()
      s.s = Str(i/40-1)
      MovePathCursor(w/2, h-40)
      RotateCoordinates(w/2, h/2, 360-i)
      ;AddPathCircle(PathCursorX(), PathCursorY(), 2)
      MovePathCursor(-VectorTextWidth(s)/2.0, -VectorTextHeight(s)/2.0, #PB_Path_Relative)
      DrawVectorText(s)
      RestoreVectorState()

Re: RotateCoordinates

Posted: Thu Sep 19, 2019 6:26 pm
by User_Russian
Thank you, this is what was needed.