(Solved) [6.0 LTS x64] Vector -> RotateCoordinates + PathPointX bad results

Just starting out? Need help? Post your questions and find answers here.
User avatar
Itsy Bitsy
New User
New User
Posts: 3
Joined: Mon Jun 24, 2019 12:32 pm

(Solved) [6.0 LTS x64] Vector -> RotateCoordinates + PathPointX bad results

Post by Itsy Bitsy »

Hi,

There seems to be a bad result with RotateCoordinates and PathPointX, …

Could you check, please ?

Thanks.

Code: Select all

; PureBasic 6.00 LTS (Windows - x64) WIN 10

IF OpenWindow(0,0,0,600,600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)=0
  
  End
  
Endif

CanvasGadget(0,0,0,600,600)

If StartVectorDrawing(CanvasVectorOutput(0))
  
  x_start=200
  y_start=200
  
  MovePathCursor(x_start,y_start)
  
  distance.d=PathLength()
  
  Debug StrD(PathCursorX())+" "+StrD(PathCursorY())                                                                         ; 200 200
  Debug StrD(distance)+" : ("+StrD(PathPointX(distance))+" "+StrD(PathPointY(distance))+") "+StrD(PathPointAngle(distance)) ; 0 : (0 0) 0
  
  ; *** DRAW LINE RIGHT ***
  
  AddPathLine(100,0,#PB_Path_Relative)
  
  distance.d=PathLength()
  
  Debug StrD(PathCursorX())+" "+StrD(PathCursorY())                                                                         ; 300 200
  Debug StrD(distance)+" : ("+StrD(PathPointX(distance))+" "+StrD(PathPointY(distance))+") "+StrD(PathPointAngle(distance)) ; 100 : (300 200) 0
  
  ; *** DRAW LINE DOWN ***
  
  AddPathLine(0,100,#PB_Path_Relative)
  
  distance.d=PathLength()
  
  Debug StrD(PathCursorX())+" "+StrD(PathCursorY())                                                                         ; 300 300
  Debug StrD(distance)+" : ("+StrD(PathPointX(distance))+" "+StrD(PathPointY(distance))+") "+StrD(PathPointAngle(distance)) ; 200 : (300 300) 90
  
  ; *** DRAW LINE LEFT AFTER ROTATE BY DRAW LINE UP ***
  
  RotateCoordinates(0,0,90)                                                                                                 ; BUG AFTER RotateCoordinates
  
  ; ***
    
  distance.d=PathLength()
  
  Debug StrD(PathCursorX())+" "+StrD(PathCursorY())                                                                         ; (BUG ? -> ) 299.9999694824 -300
  Debug StrD(distance)+" : ("+StrD(PathPointX(distance))+" "+StrD(PathPointY(distance))+") "+StrD(PathPointAngle(distance)) ; (BUG ? -> ) 199.9999694824 : (299.9999694824 -300) 0
  
  AddPathLine(0,100,#PB_Path_Relative)
  
  Debug StrD(PathCursorX())+" "+StrD(PathCursorY())                                                                         ; (BUG ? -> ) 299.9999694824 -200
  Debug StrD(distance)+" : ("+StrD(PathPointX(distance))+" "+StrD(PathPointY(distance))+") "+StrD(PathPointAngle(distance)) ; (BUG ? -> ) 199.9999694824 : (299.9999694824 -300) 0
  
  ; ***
  
  VectorSourceColor(RGBA(255, 0, 0, 255))                                                                                   ; VECTOR DRAW IS GOOD
  
  StrokePath(1)
  
  StopVectorDrawing()
  
  ; *** REDRAW BY COORDINATES BUGGEES
  
  offset_x=200
  offset_y=0
  
  If StartDrawing(CanvasOutput(0))
    
    LINEXY(offset_x+200,offset_y+200,offset_x+300,offset_y+200,$FF0000)
    LINEXY(offset_x+300,offset_y+200,offset_x+300,offset_y+300,$00FF00)
    LINEXY(offset_x+300,offset_y+300,offset_x+200,offset_y+(-300),$0000FF)                                                  ; NO GOOD
    
    StopDrawing()
        
  Endif
  
  ; *** REDRAW BY COORDINATES WITH GOOD COORDINATES
  
  offset_x=200
  offset_y=200
  
  If StartDrawing(CanvasOutput(0))
    
    LINEXY(offset_x+200,offset_y+200,offset_x+300,offset_y+200,$FF0000)
    LINEXY(offset_x+300,offset_y+200,offset_x+300,offset_y+300,$00FF00)
    LINEXY(offset_x+300,offset_y+300,offset_x+200,offset_y+300,$0000FF)
    
    StopDrawing()
        
  Endif
  
Endif

Repeat
  
  Event = WaitWindowEvent()
  
Until Event = #PB_Event_CloseWindow
// Moved from "Bugs - Windows" to "Coding Questions" (Kiffi)
// @Itsy Bitsy: Please read this before reporting errors in the future.
Last edited by Itsy Bitsy on Sat Aug 06, 2022 9:05 am, edited 1 time in total.
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: [6.0 LTS x64] Vector -> RotateCoordinates + PathPointX bad results

Post by Olli »

Hello,

try this :

Code: Select all

RotateCoordinates(PathCursorX(), PathCursorY(), 90)
This rotates your graphic cursor from the place where it is.
User avatar
Itsy Bitsy
New User
New User
Posts: 3
Joined: Mon Jun 24, 2019 12:32 pm

(Solved) [6.0 LTS x64] Vector -> RotateCoordinates + PathPointX bad results

Post by Itsy Bitsy »

Hello Olli,

Thank you for your help, and your solution which works perfectly.

I thought 0.0 was the cursor position.

Thank you, again.

Code: Select all

; PureBasic 6.00 LTS (Windows - x64) WIN 10

IF OpenWindow(0,0,0,600,600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)=0
  
  End
  
Endif

CanvasGadget(0,0,0,600,600)

If StartVectorDrawing(CanvasVectorOutput(0))
  
  x_start=200
  y_start=200
  
  MovePathCursor(x_start,y_start)
  
  distance.d=PathLength()
  
  Debug StrD(PathCursorX())+" "+StrD(PathCursorY())                                                                         ; 200 200
  Debug StrD(distance)+" : ("+StrD(PathPointX(distance))+" "+StrD(PathPointY(distance))+") "+StrD(PathPointAngle(distance)) ; 0 : (0 0) 0
  
  ; *** DRAW LINE RIGHT ***
  
  AddPathLine(100,0,#PB_Path_Relative)
  
  distance.d=PathLength()
  
  Debug StrD(PathCursorX())+" "+StrD(PathCursorY())                                                                         ; 300 200
  Debug StrD(distance)+" : ("+StrD(PathPointX(distance))+" "+StrD(PathPointY(distance))+") "+StrD(PathPointAngle(distance)) ; 100 : (300 200) 0
  
  ; *** DRAW LINE DOWN ***
  
  AddPathLine(0,100,#PB_Path_Relative)
  
  distance.d=PathLength()
  
  Debug StrD(PathCursorX())+" "+StrD(PathCursorY())                                                                         ; 300 300
  Debug StrD(distance)+" : ("+StrD(PathPointX(distance))+" "+StrD(PathPointY(distance))+") "+StrD(PathPointAngle(distance)) ; 200 : (300 300) 90
  
  ; *** DRAW LINE LEFT AFTER ROTATE BY DRAW LINE UP ***
  
  RotateCoordinates(PathCursorX(),PathCursorY(),90)                                                                         ; Solved by Olli
  
  ; ***
    
  distance.d=PathLength()
  
  Debug StrD(PathCursorX())+" "+StrD(PathCursorY())                                                                         ; 300 300
  Debug StrD(distance)+" : ("+StrD(PathPointX(distance))+" "+StrD(PathPointY(distance))+") "+StrD(PathPointAngle(distance)) ; 200 : (300 300) 0
  
  AddPathLine(0,100,#PB_Path_Relative)
  
  Debug StrD(PathCursorX())+" "+StrD(PathCursorY())                                                                         ; 300 400
  Debug StrD(distance)+" : ("+StrD(PathPointX(distance))+" "+StrD(PathPointY(distance))+") "+StrD(PathPointAngle(distance)) ; 200 : (300 300) 0
  
  ; ***
  
  VectorSourceColor(RGBA(255, 0, 0, 255))                                                                                   ; VECTOR DRAW IS GOOD
  
  StrokePath(1)
  
  StopVectorDrawing()
  
  ; *** REDRAW BY COORDINATES BUGGEES
  
  offset_x=200
  offset_y=0
  
  If StartDrawing(CanvasOutput(0))
    
    LINEXY(offset_x+200,offset_y+200,offset_x+300,offset_y+200,$FF0000)
    LINEXY(offset_x+300,offset_y+200,offset_x+300,offset_y+300,$00FF00)
    LINEXY(offset_x+300,offset_y+300,offset_x+200,offset_y+300,$0000FF)
    
    StopDrawing()
        
  Endif
  
  ; *** REDRAW BY COORDINATES WITH GOOD COORDINATES
  
  offset_x=200
  offset_y=200
  
  If StartDrawing(CanvasOutput(0))
    
    LINEXY(offset_x+200,offset_y+200,offset_x+300,offset_y+200,$FF0000)
    LINEXY(offset_x+300,offset_y+200,offset_x+300,offset_y+300,$00FF00)
    LINEXY(offset_x+300,offset_y+300,offset_x+200,offset_y+300,$0000FF)
    
    StopDrawing()
        
  Endif
  
Endif

Repeat
  
  Event = WaitWindowEvent()
  
Until Event = #PB_Event_CloseWindow
Post Reply