hola
prueba el siguiente código:
se basa en determinar en el tiempo de la transición el valor que han de tener los cuatro puntos del panel, para lo cual se utiliza una función lineal donde x=0 es la posición inicial y x=AStep es el valor final, tenindo AStep el numero de pasos en que se quiere hacer la transición
Código Delphi
[-]
type
TFLineal = record
private
a, b: Extended;
function GetPoint(const x: Integer): Integer;
public
procedure init(const X1, y1, x2, y2: Integer);
property Point[const x: Integer]: Integer read GetPoint; default;
end;
...
function TFLineal.GetPoint(const x: Integer): Integer;
begin
Result := round(a * x + b);
end;
procedure TFLineal.init(const X1, y1, x2, y2: Integer);
begin
a := (y2 - y1) / (x2 - X1);
b := y1 - a * X1;
end;
y en la parte del formulario:
Código Delphi
[-]
var
fLeft, fWidth, fTop, fHeight: TFLineal;
...
procedure TForm2.AnimeConfig(AWinControl: TWinControl; const AWidth, AHeight,
AStep: Word);
begin
fLeft.init(0, AWinControl.left, AStep, (ClientWidth - AWidth) div 2);
fWidth.init(0, AWinControl.width, AStep, AWidth);
fTop.init(0, AWinControl.top, AStep, (ClientHeight - AHeight) div 2);
fHeight.init(0, AWinControl.height, AStep, AHeight);
end;
procedure TForm2.AnimeExecute(AWinControl: TWinControl; const AStep: Word);
var
i, Ai: longint;
tSleep:Word;
begin
tSleep := 300 div AStep;
if Tag <= 0 then begin
i := 1;
Ai := 1
end
else begin
i := AStep - 1;
Ai := -1;
end;
repeat
with AWinControl do begin
Left := fLeft[i];
Top := fTop[i];
Width := fWidth[i];
Height := fHeight[i];
end;
Sleep(tSleep);
i := i + Ai;
until (i <= 0) or (i >= AStep);
self.Tag := i;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
AnimeConfig(Panel1, Width - 50, height - 300);
end;
procedure TForm2.Panel1DblClick(Sender: TObject);
begin
AnimeExecute(Panel1);
end;