Einzelnen Beitrag anzeigen

Blup

Registriert seit: 7. Aug 2008
Ort: Brandenburg
1.464 Beiträge
 
Delphi 12 Athens
 
#4

AW: Rechteck skalieren

  Alt 19. Okt 2016, 10:48
Ungetestet:
Delphi-Quellcode:
// Dest.Left := Max(Dest.Left, Bounds.Left);
// Dest.Top := Max(Dest.Top, Bounds.Top);
// Dest.Right := Min(Dest.Right, Bounds.Right);
// Dest.Bottom := Min(Dest.Bottom, Bounds.Bottom);

  FaktorX := (Src.Right - Src.Left) / (Dest.Right - Dest.Left);
  FaktorY := (Src.Bottom - Src.Top) / (Dest.Bottom - Dest.Top);

  if Bounds.Left > Dest.Left then
  begin
    Src.Left := Src.Left + (Bounds.Left - Dest.Left) * FaktorX;
    Dest.Left := Bounds.Left;
  end;

  if Bounds.Top > Dest.Top then
  begin
    Src.Top := Src.Top + (Bounds.Top - Dest.Top) * FaktorY;
    Dest.Top := Bounds.Top;
  end;

  if Bounds.Right < Dest.Right then
  begin
    Src.Right := Src.Right + (Bounds.Right - Dest.Right) * FaktorX;
    Dest.Top := Bounds.Right;
  end;
  
  if Bounds.Bottom < Dest.Bottom then
  begin
    Src.Bottom := Src.Bottom + (Bounds.Bottom - Dest.Bottom) * FaktorY;
    Dest.Bottom := Bounds.Bottom;
  end;
  Mit Zitat antworten Zitat