ConvertCoordinateX()

Syntax

Result.d = ConvertCoordinateX(x.d, y.d [, Source, Target])
Description
Convert a point from one coordinate system to another in the vector drawing output. This function returns the X coordinate of the conversion. The Y coordinate can be retrieved with the ConvertCoordinateY() function.

Parameters

x.d, y.d Specifies the coordinates of the point to convert in terms of the source coordinate system.
Source, Target (optional) Specifies the source and target coordinates for the conversion. Each can be one of these values:
  #PB_Coordinate_Device: The coordinate system of the output device
  #PB_Coordinate_Output: The coordinate system as it was created with the drawing output function
  #PB_Coordinate_User  : The coordinate system for points in the drawing path
  #PB_Coordinate_Source: The coordinate system for the vector drawing source
The default conversion is from #PB_Coordinate_User to #PB_Coordinate_Output.

Return value

Returns the X coordinate of the point in the target coordinate system.

Remarks

See the vectordrawing overview for an introduction to the different coordinate systems.

Example

  ; This example draws a dot at the mouse location even in a modified coordinate system
  ; by mapping the coordinates from the device system (pixels) to the user system (points)
  ;
  If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CanvasGadget(0, 0, 0, 400, 200)   
    
    Repeat
      Event = WaitWindowEvent()
      
      If Event = #PB_Event_Gadget And EventGadget() = 0 And EventType() = #PB_EventType_LeftButtonDown
        
        If StartVectorDrawing(CanvasVectorOutput(0, #PB_Unit_Point))
          RotateCoordinates(0, 0, 30)
          
          CanvasX = GetGadgetAttribute(0, #PB_Canvas_MouseX)
          CanvasY = GetGadgetAttribute(0, #PB_Canvas_MouseY)
          
          DrawingX = ConvertCoordinateX(CanvasX, CanvasY, #PB_Coordinate_Device, #PB_Coordinate_User)
          DrawingY = ConvertCoordinateY(CanvasX, CanvasY, #PB_Coordinate_Device, #PB_Coordinate_User)
          
          AddPathCircle(DrawingX, DrawingY, 10)
          VectorSourceColor(RGBA(Random(255), Random(255), Random(255), 255))
          FillPath()
        
          StopVectorDrawing()
        EndIf
        
      EndIf
      
    Until Event = #PB_Event_CloseWindow
  EndIf

See Also

ResetCoordinates(), TranslateCoordinates(), ScaleCoordinates(), RotateCoordinates(), SkewCoordinates(), FlipCoordinatesX(), FlipCoordinatesY(), ConvertCoordinateY()

Supported OS

All

<- ClosePath() - VectorDrawing Index - ConvertCoordinateY() ->