AggPas - Anti-Grain Geomertry for Object Pascal

TAgg2D.WorldToScreen(x, y)

Description

Transforms world (user) coordinates into surface (screen) coordinates.

World (user) coordinates are units of measure [in subpixels] in which developer defines the positions and dimensions of objects willing to be drawn.

Surface (screen) coordinates are computed by vector graphics engine from world (user) coordinates in the process of rendering by multiplying with affine matrix.

Resulting screen coordinates are fractional numbers [in subpixels], despite the fact that the destination surface (eg. screen) has a final non-fractional integer displaying units (pixels). The effect of fractional shift in position is then achieved optically with Anti Aliasing.

Converting coordinates from world to screen units is good for calculating the resulting positions and dimensions of objects being drawn on screen.

Parameters

x: PDouble

Pointer to the world X coordinate [in subpixels]. This parameter receives also the result of conversion — screen X coordinate [in subpixels].

y: PDouble

Pointer to the world Y coordinate [in subpixels]. This parameter receives also the result of conversion — screen Y coordinate [in subpixels].

Example

var
  x, y: double;
begin
  if VG.Attach(Image1.Picture.Bitmap) then begin

    VG.ClearAll (255, 255, 255);

    // Coordinates system shift (on X + 10, on Y + 20)
    VG.Translate(10, 20);

    // Find out where on screen x & y will be
    x := 15;
    y := 15;

    VG.WorldToScreen(@x, @y);
    // X should be 25 (15 + 10), Y should be 35 (15 + 20)

  end;
end;