Skip to content

Latest commit

 

History

History
44 lines (36 loc) · 1.38 KB

FMXBezierAnimation.md

File metadata and controls

44 lines (36 loc) · 1.38 KB

FMXBezierAnimation

TFMXBezierAnimation component inherit from TFloatAnimation, you can just drop a TFMXBezierAnimation component same as TFloatAnimation.

use these code to set the cubic-bezier parameters

  BezierAnimation1.Duration := duration; 
  BezierAnimation1.SetData(X1, Y1, X2, Y2);
  BezierAnimation1.Start;

This is the interface of TBezier

  TBezier = class
  public
    constructor Create(p1x, p1y, p2x, p2y: Double);
    procedure SetData(p1x, p1y, p2x, p2y: Double);
    function SampleCurveX(t: Double): Double;
    function SampleCurveY(t: Double): Double;
    function SampleCurveDerivativeX(t: Double): Double;
    function SolveCurveX(x, epsilon: Double): Double;
    function Solve(x, epsilon: Double): Double;
    class function GetLinear: TBezier;
    class function GetEase: TBezier;
    class function GetEaseIn: TBezier;
    class function GetEaseOut: TBezier;
    class function GetEaseInOut: TBezier;
  end;

there are 5 predefined bezier curves, linear, ease, ease-in, ease-out, ease-in-out, you can call corresponding class function to get the curve.

  Ani := TBezier.GetEaseInOut;
  BezierAnimation1.SetBezier(Ani);

or you can defined your curve

  Ani := TBezier.Create(p1x, p1y, p2x, p2y);