WladiD / AnyiQuack

Animation framework for Delphi
64 stars 19 forks source link

Font.Size #12

Closed kazuser closed 11 months ago

kazuser commented 11 months ago

Hi there! Is it possible to animate Font.Size? 🤔

uses
  Vcl.StdCtrls

...

    function FontSizeAnimation(FromSize, ToSize, Duration: Integer; ID: Integer = 0;
      const EaseFunction: TEaseFunction = nil; const OnComplete: TAnonymNotifyEvent = nil): TAQ;

...

function TAQPControlAnimations.FontSizeAnimation(FromSize, ToSize, Duration, ID: Integer;
  const EaseFunction: TEaseFunction; const OnComplete: TAnonymNotifyEvent): TAQ;
begin
  Result := Each(
    function(AQ: TAQ; O: TObject): Boolean
    begin
      Result := True;

      Take(O)
        .EachAnimation(Duration,
          function(AQ: TAQ; O: TObject): Boolean
          begin
            TLabel(O).Font.Size := Byte(TAQ.EaseInteger(
              FromSize, ToSize, AQ.CurrentInterval.Progress,
              EaseFunction));

            if Assigned(OnComplete) and (AQ.CurrentInterval.Progress = 1) then
              OnComplete(O);

            Result := True;
          end);
    end);
end;

F9:

procedure Button1Click(Sender: TObject);
begin
  Take(Label1)
     .Plugin<TAQPControlAnimations>
     .FontSizeAnimation(Label1.Font.Size, 12, 1, 1000);
end;

Result: 0

kazuser commented 11 months ago

Ooops))) "Duration" <> "ID" 😂