AggPas - Anti-Grain Geomertry for Object Pascal

TAgg2D.Transformations(tr)

Description

Replaces currently used affine transformations matrix with the one supplied by user. This allows for applying a user defined non-standard transformations.

Parameters

tr: PAggTransformations

Pointer to the data structure containing custom affine transformations matrix.

Example

var
  x, y, nx, ny: double;

if VG.Attach(Image1.Picture.Bitmap) then begin

  VG.ClearAll(255, 255, 255);
  VG.NoLine;

  // Red Arrow
  VG.FillColor(255, 0, 0, 128);
  VG.Triangle (100, 20, 40, 100, 160, 100);
  VG.Rectangle(70, 100, 130, 170);

  // Coordinates will be reflected along line
  // defined as from 0:0 to 90:85
  x := 90;
  y := 85;

  nx := x / Sqrt(x * x + y * y);
  ny := y / Sqrt(x * x + y * y);

  af.affineMatrix[0] := 2.0 * nx * nx - 1.0;
  af.affineMatrix[1] := 2.0 * nx * ny;
  af.affineMatrix[2] := 2.0 * nx * ny;
  af.affineMatrix[3] := 2.0 * ny * ny - 1.0;
  af.affineMatrix[4] := 0.0;
  af.affineMatrix[5] := 0.0;

  // Add Reflection Transformation by utilizing
  // custom matrix set-up function
  VG.Transformations(@af);

  // Blue Arrow (same as Red)
  VG.FillColor(0, 0, 255, 128);
  VG.Triangle (100, 20, 40, 100, 160, 100);
  VG.Rectangle(70, 100, 130, 170);

end;

Screenshot: example