unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls, FMX.Edit, FMX.Objects, FMX.Ani;
type
TForm1 =
class(TForm)
Rectangle1: TRectangle;
Rectangle2: TRectangle;
Rectangle3: TRectangle;
procedure Rectangle2Click(Sender: TObject);
procedure Rectangle1Click(Sender: TObject);
procedure Rectangle3Click(Sender: TObject);
private
procedure ani(Sender: TObject; Color: TAlphaColor);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Rectangle1Click(Sender: TObject);
begin
ani(Rectangle1,TAlphaColorRec.Red);
end;
procedure TForm1.Rectangle2Click(Sender: TObject);
begin
ani(Rectangle2,TAlphaColorRec.Green);
end;
procedure TForm1.Rectangle3Click(Sender: TObject);
begin
ani(Rectangle3,TAlphaColorRec.Blue);
end;
procedure TForm1.ani(Sender: TObject; Color: TAlphaColor);
var origColor : TAlphaColor;
begin
if sender
is TRectangle
then
begin
// welche Farbe hatte TRectangle vor der Animation?
origColor := (sender
as TRectangle).Fill.Color;
// set animation Color
(sender
as TRectangle).AnimateColor('
Fill.Color', Color, 0.5, TAnimationType.InOut,
TInterpolationType.Linear);
// reset original Color
(sender
as TRectangle).AnimateColor('
Fill.Color', origColor, 0.5, TAnimationType.InOut,
TInterpolationType.Linear);
end;
end;
end.