RenderTarget.mapCoordsToPixel

Convert a point from world coordinates to target coordinates.

This function finds the pixel of the render-target that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-target – if the view is translated by (140, 25).

This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.

  1. Vector2i mapCoordsToPixel(Vector2f point)
  2. Vector2i mapCoordsToPixel(Vector2f point, View theView)
    interface RenderTarget
    final inout
    mapCoordsToPixel

Parameters

point Vector2f

Point to convert

theView View

The view to use for converting the point

Return Value

Type: Vector2i

The converted point, in target coordinates (pixels).

Meta