2009. március 3., kedd

How to zoom a polygon


Problem/Question/Abstract:

How can I zoom a polygon? Using SetWorldTransform or how?

Answer:

Here's one possible way:

{ ... }
type
  TPolygon = array of TPoint;

procedure ZoomPolygon(var Polygon: TPolygon; const Center: TPoint; const Scale: Double);
var
  I: Integer;
begin
  for I := 0 to High(Polygon) do
  begin
    Polygon[I].X := Round(Scale * (Polygon[I].X - Center.X) + Center.X);
    Polygon[I].Y := Round(Scale * (Polygon[I].Y - Center.Y) + Center.Y);
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése