├── README.md ├── Demo.res ├── Demo.dpr ├── .gitignore ├── Form.Animation.pas ├── UCL.IntAnimation.Helpers.pas ├── Form.Animation.dfm ├── UCL.IntAnimation.pas ├── UCL.IntAnimation.Collection.pas └── Demo.dproj /README.md: -------------------------------------------------------------------------------- 1 | # AniVCL 2 | Animation library for Delphi VCL 3 | -------------------------------------------------------------------------------- /Demo.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tonghoangvu/AniVCL/HEAD/Demo.res -------------------------------------------------------------------------------- /Demo.dpr: -------------------------------------------------------------------------------- 1 | program Demo; 2 | 3 | uses 4 | Vcl.Forms, 5 | Form.Animation in 'Form.Animation.pas' {formAnimation}, 6 | UCL.IntAnimation.Collection in 'UCL.IntAnimation.Collection.pas', 7 | UCL.IntAnimation.Helpers in 'UCL.IntAnimation.Helpers.pas', 8 | UCL.IntAnimation in 'UCL.IntAnimation.pas'; 9 | 10 | {$R *.res} 11 | 12 | begin 13 | ReportMemoryLeaksOnShutDown := True; 14 | Application.Initialize; 15 | Application.MainFormOnTaskbar := True; 16 | Application.CreateForm(TformAnimation, formAnimation); 17 | Application.Run; 18 | end. 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Uncomment these types if you want even more clean repository. But be careful. 2 | # It can make harm to an existing project source. Read explanations below. 3 | # 4 | # Resource files are binaries containing manifest, project icon and version info. 5 | # They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files. 6 | #*.res 7 | # 8 | # Type library file (binary). In old Delphi versions it should be stored. 9 | # Since Delphi 2009 it is produced from .ridl file and can safely be ignored. 10 | #*.tlb 11 | # 12 | # Diagram Portfolio file. Used by the diagram editor up to Delphi 7. 13 | # Uncomment this if you are not using diagrams or use newer Delphi version. 14 | #*.ddp 15 | # 16 | # Visual LiveBindings file. Added in Delphi XE2. 17 | # Uncomment this if you are not using LiveBindings Designer. 18 | #*.vlb 19 | # 20 | # Deployment Manager configuration file for your project. Added in Delphi XE2. 21 | # Uncomment this if it is not mobile development and you do not use remote debug feature. 22 | #*.deployproj 23 | # 24 | # C++ object files produced when C/C++ Output file generation is configured. 25 | # Uncomment this if you are not using external objects (zlib library for example). 26 | #*.obj 27 | # 28 | 29 | # Delphi compiler-generated binaries (safe to delete) 30 | *.exe 31 | *.dll 32 | *.bpl 33 | *.bpi 34 | *.dcp 35 | *.so 36 | *.apk 37 | *.drc 38 | *.map 39 | *.dres 40 | *.rsm 41 | *.tds 42 | *.dcu 43 | *.lib 44 | *.a 45 | *.o 46 | *.ocx 47 | 48 | # Delphi autogenerated files (duplicated info) 49 | *.cfg 50 | *.hpp 51 | *Resource.rc 52 | 53 | # Delphi local files (user-specific info) 54 | *.local 55 | *.identcache 56 | *.projdata 57 | *.tvsconfig 58 | *.dsk 59 | 60 | # Delphi history and backups 61 | __history/ 62 | __recovery/ 63 | *.~* 64 | 65 | # Castalia statistics file (since XE7 Castalia is distributed with Delphi) 66 | *.stat 67 | -------------------------------------------------------------------------------- /Form.Animation.pas: -------------------------------------------------------------------------------- 1 | unit Form.Animation; 2 | 3 | interface 4 | 5 | uses 6 | UCL.IntAnimation, UCL.IntAnimation.Helpers, 7 | Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, 8 | Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls; 9 | 10 | type 11 | TformAnimation = class(TForm) 12 | buttonAni: TButton; 13 | buttonStartWithHelper: TButton; 14 | buttonStartAnimation: TButton; 15 | radiogroupAniKind: TRadioGroup; 16 | radiogroupAniFunction: TRadioGroup; 17 | groupCustomAniOptions: TGroupBox; 18 | editStep: TLabeledEdit; 19 | editDuration: TLabeledEdit; 20 | editStartValue: TLabeledEdit; 21 | editDeltaValue: TLabeledEdit; 22 | buttonResetPosition: TButton; 23 | procedure buttonStartAnimationClick(Sender: TObject); 24 | procedure buttonStartWithHelperClick(Sender: TObject); 25 | procedure buttonResetPositionClick(Sender: TObject); 26 | private 27 | { Private declarations } 28 | public 29 | { Public declarations } 30 | end; 31 | 32 | var 33 | formAnimation: TformAnimation; 34 | 35 | implementation 36 | 37 | {$R *.dfm} 38 | 39 | procedure TformAnimation.buttonStartWithHelperClick(Sender: TObject); 40 | begin 41 | buttonAni.AnimationFromCurrent(apTop, +100, 35, 400, akOut, afkBounce, 42 | procedure begin buttonAni.SetFocus end); 43 | end; 44 | 45 | procedure TformAnimation.buttonResetPositionClick(Sender: TObject); 46 | begin 47 | buttonAni.Top := 20; 48 | buttonAni.Left := 20; 49 | end; 50 | 51 | procedure TformAnimation.buttonStartAnimationClick(Sender: TObject); 52 | var 53 | Ani: TIntAni; 54 | begin 55 | Ani := TIntAni.Create(true, akIn, afkLinear, 20, +300, 56 | procedure (V: Integer) 57 | begin 58 | buttonAni.Left:= V; 59 | end); 60 | Ani.AniKind := TAniKind(radiogroupAniKind.ItemIndex); 61 | Ani.AniFunctionKind := TAniFunctionKind(radiogroupAniFunction.ItemIndex); 62 | 63 | Ani.Step := StrToIntDef(editStep.Text, 25); 64 | Ani.Duration := StrToIntDef(editDuration.Text, 250); 65 | Ani.StartValue := StrToIntDef(editStartValue.Text, 20); 66 | Ani.DeltaValue := StrToIntDef(editDeltaValue.Text, +300); 67 | 68 | Ani.Start; 69 | end; 70 | 71 | end. 72 | -------------------------------------------------------------------------------- /UCL.IntAnimation.Helpers.pas: -------------------------------------------------------------------------------- 1 | unit UCL.IntAnimation.Helpers; 2 | 3 | interface 4 | 5 | uses 6 | UCL.IntAnimation, 7 | VCL.Controls; 8 | 9 | type 10 | TAnimationProp = ( 11 | apTop, apLeft, apWidth, apHeight, 12 | apMarginTop, apMarginLeft, apMarginRight, apMarginBottom, 13 | apPaddingTop, apPaddingLeft, apPaddingRight, apPaddingBottom 14 | ); 15 | 16 | TWinControlHelper = class helper for TWinControl 17 | function GetPropValue(Prop: TAnimationProp): Integer; 18 | procedure SetPropValue(Prop: TAnimationProp; Value: Integer); 19 | 20 | procedure Animation( 21 | AniProperty: TAnimationProp; 22 | StartValue, DeltaValue: Integer; Step, Duration: Cardinal; 23 | AniKind: TAniKind; AniFunctionKind: TAniFunctionKind; 24 | OnDone: TAniDoneProc); 25 | procedure AnimationFromCurrent( 26 | AniProperty: TAnimationProp; 27 | DeltaValue: Integer; Step, Duration: Cardinal; 28 | AniKind: TAniKind; AniFunctionKind: TAniFunctionKind; 29 | OnDone: TAniDoneProc); 30 | end; 31 | 32 | implementation 33 | 34 | { TWinControlHelper } 35 | 36 | procedure TWinControlHelper.Animation( 37 | AniProperty: TAnimationProp; 38 | StartValue, DeltaValue: Integer; Step, Duration: Cardinal; 39 | AniKind: TAniKind; AniFunctionKind: TAniFunctionKind; 40 | OnDone: TAniDoneProc); 41 | var 42 | Ani: TIntAni; 43 | begin 44 | Ani := TIntAni.Create(True, AniKind, AniFunctionKind, StartValue, DeltaValue, 45 | procedure (V: Integer) 46 | begin 47 | SetPropValue(AniProperty, V); 48 | end); 49 | Ani.Step := Step; 50 | Ani.Duration := Duration; 51 | 52 | Ani.OnDone := OnDone; 53 | Ani.Start; 54 | end; 55 | 56 | procedure TWinControlHelper.AnimationFromCurrent( 57 | AniProperty: TAnimationProp; DeltaValue: Integer; Step, 58 | Duration: Cardinal; AniKind: TAniKind; AniFunctionKind: TAniFunctionKind; 59 | OnDone: TAniDoneProc); 60 | begin 61 | Animation(AniProperty, GetPropValue(AniProperty), DeltaValue, Step, Duration, 62 | AniKind, AniFunctionKind, OnDone); 63 | end; 64 | 65 | // PROPERTY 66 | 67 | function TWinControlHelper.GetPropValue(Prop: TAnimationProp): Integer; 68 | begin 69 | case Prop of 70 | apTop: 71 | Result := Top; 72 | apLeft: 73 | Result := Left; 74 | apWidth: 75 | Result := Width; 76 | apHeight: 77 | Result := Height; 78 | apMarginTop: 79 | Result := Margins.Top; 80 | apMarginLeft: 81 | Result := Margins.Left; 82 | apMarginRight: 83 | Result := Margins.Right; 84 | apMarginBottom: 85 | Result := Margins.Bottom; 86 | apPaddingTop: 87 | Result := Padding.Top; 88 | apPaddingLeft: 89 | Result := Padding.Left; 90 | apPaddingRight: 91 | Result := Padding.Right; 92 | apPaddingBottom: 93 | Result := Padding.Bottom; 94 | else 95 | Result := -1; 96 | end; 97 | end; 98 | 99 | procedure TWinControlHelper.SetPropValue(Prop: TAnimationProp; Value: Integer); 100 | begin 101 | case Prop of 102 | apTop: 103 | Top := Value; 104 | apLeft: 105 | Left := Value; 106 | apWidth: 107 | Width := Value; 108 | apHeight: 109 | Height := Value; 110 | 111 | apMarginTop: 112 | Margins.Top := Value; 113 | apMarginLeft: 114 | Margins.Left := Value; 115 | apMarginRight: 116 | Margins.Right := Value; 117 | apMarginBottom: 118 | Margins.Bottom := Value; 119 | 120 | apPaddingTop: 121 | Padding.Top := Value; 122 | apPaddingLeft: 123 | Padding.Left := Value; 124 | apPaddingRight: 125 | Padding.Right := Value; 126 | apPaddingBottom: 127 | Padding.Bottom := Value; 128 | end; 129 | end; 130 | 131 | end. 132 | -------------------------------------------------------------------------------- /Form.Animation.dfm: -------------------------------------------------------------------------------- 1 | object formAnimation: TformAnimation 2 | Left = 0 3 | Top = 0 4 | Caption = 'TIntAnimation test' 5 | ClientHeight = 372 6 | ClientWidth = 799 7 | Color = clWhite 8 | Ctl3D = False 9 | Font.Charset = DEFAULT_CHARSET 10 | Font.Color = clWindowText 11 | Font.Height = -13 12 | Font.Name = 'Segoe UI' 13 | Font.Style = [] 14 | Font.Quality = fqClearType 15 | Padding.Left = 20 16 | Padding.Top = 70 17 | Padding.Right = 20 18 | Padding.Bottom = 20 19 | OldCreateOrder = False 20 | Visible = True 21 | PixelsPerInch = 96 22 | TextHeight = 17 23 | object buttonAni: TButton 24 | Left = 20 25 | Top = 20 26 | Width = 75 27 | Height = 41 28 | Caption = 'Me' 29 | TabOrder = 0 30 | end 31 | object buttonStartWithHelper: TButton 32 | Left = 118 33 | Top = 245 34 | Width = 133 35 | Height = 36 36 | Caption = 'Start by helper' 37 | TabOrder = 1 38 | WordWrap = True 39 | OnClick = buttonStartWithHelperClick 40 | end 41 | object buttonStartAnimation: TButton 42 | Left = 118 43 | Top = 195 44 | Width = 133 45 | Height = 36 46 | Caption = 'Start' 47 | TabOrder = 2 48 | OnClick = buttonStartAnimationClick 49 | end 50 | object radiogroupAniKind: TRadioGroup 51 | Left = 121 52 | Top = 78 53 | Width = 130 54 | Height = 103 55 | Caption = 'Animation kind' 56 | ItemIndex = 0 57 | Items.Strings = ( 58 | 'akIn' 59 | 'akOut' 60 | 'akInOut') 61 | TabOrder = 3 62 | end 63 | object radiogroupAniFunction: TRadioGroup 64 | AlignWithMargins = True 65 | Left = 291 66 | Top = 78 67 | Width = 470 68 | Height = 103 69 | Margins.Left = 0 70 | Margins.Top = 20 71 | Margins.Right = 0 72 | Margins.Bottom = 0 73 | Caption = 'Animation function' 74 | Columns = 4 75 | ItemIndex = 0 76 | Items.Strings = ( 77 | 'afkLinear' 78 | 'afkQuadratic' 79 | 'afkCubic' 80 | 'afkQuartic' 81 | 'afkQuintic' 82 | 'afkBack' 83 | 'afkBounce' 84 | 'afkExpo' 85 | 'afkSine' 86 | 'afkCircle') 87 | TabOrder = 4 88 | end 89 | object groupCustomAniOptions: TGroupBox 90 | AlignWithMargins = True 91 | Left = 291 92 | Top = 191 93 | Width = 470 94 | Height = 140 95 | Margins.Left = 0 96 | Margins.Top = 20 97 | Margins.Right = 0 98 | Margins.Bottom = 0 99 | Caption = 'Other options' 100 | TabOrder = 5 101 | object editStep: TLabeledEdit 102 | Left = 19 103 | Top = 40 104 | Width = 100 105 | Height = 23 106 | EditLabel.Width = 26 107 | EditLabel.Height = 17 108 | EditLabel.Caption = 'Step' 109 | NumbersOnly = True 110 | TabOrder = 0 111 | Text = '25' 112 | end 113 | object editDuration: TLabeledEdit 114 | Left = 189 115 | Top = 40 116 | Width = 100 117 | Height = 23 118 | EditLabel.Width = 79 119 | EditLabel.Height = 17 120 | EditLabel.Caption = 'Duration (ms)' 121 | NumbersOnly = True 122 | TabOrder = 1 123 | Text = '250' 124 | end 125 | object editStartValue: TLabeledEdit 126 | Left = 19 127 | Top = 92 128 | Width = 100 129 | Height = 23 130 | EditLabel.Width = 91 131 | EditLabel.Height = 17 132 | EditLabel.Caption = 'Start value (left)' 133 | NumbersOnly = True 134 | TabOrder = 2 135 | Text = '20' 136 | end 137 | object editDeltaValue: TLabeledEdit 138 | Left = 189 139 | Top = 92 140 | Width = 100 141 | Height = 23 142 | EditLabel.Width = 99 143 | EditLabel.Height = 17 144 | EditLabel.Caption = 'Delta (signed int)' 145 | NumbersOnly = True 146 | TabOrder = 3 147 | Text = '+300' 148 | end 149 | end 150 | object buttonResetPosition: TButton 151 | Left = 118 152 | Top = 295 153 | Width = 133 154 | Height = 36 155 | Caption = 'Reset position' 156 | TabOrder = 6 157 | WordWrap = True 158 | OnClick = buttonResetPositionClick 159 | end 160 | end 161 | -------------------------------------------------------------------------------- /UCL.IntAnimation.pas: -------------------------------------------------------------------------------- 1 | unit UCL.IntAnimation; 2 | 3 | interface 4 | 5 | uses 6 | System.Classes, System.SysUtils, System.Threading; 7 | 8 | type 9 | TAniSyncProc = reference to procedure (V: Integer); 10 | TAniDoneProc = reference to procedure; // TProc 11 | 12 | TAniFunction = reference to function (P: Single): Single; 13 | 14 | TAniKind = (akIn, akOut, akInOut); 15 | TAniFunctionKind = ( 16 | afkLinear, afkQuadratic, afkCubic, afkQuartic, afkQuintic, 17 | afkBack, afkBounce, afkExpo, afkSine, afkCircle 18 | ); 19 | 20 | TIntAni = class(TThread) 21 | var CurrentValue: Integer; 22 | 23 | private 24 | var FStep: Byte; 25 | var AniFunction: TAniFunction; 26 | 27 | FOnSync: TAniSyncProc; 28 | FOnDone: TAniDoneProc; 29 | 30 | FAniKind: TAniKind; 31 | FAniFunctionKind: TAniFunctionKind; 32 | 33 | FDelayStartTime: Cardinal; 34 | FDuration: Cardinal; 35 | FStartValue: Integer; 36 | FDeltaValue: Integer; 37 | 38 | function UpdateFunction: Boolean; 39 | procedure UpdateControl; 40 | procedure DoneControl; 41 | 42 | protected 43 | procedure Execute; override; 44 | 45 | public 46 | constructor Create( 47 | FreeOnFinish: Boolean; 48 | aAniKind: TAniKind; aAniFunctionKind: TAniFunctionKind; 49 | aStartValue, aDeltaValue: Integer; 50 | aSyncProc: TAniSyncProc); 51 | 52 | // Events 53 | property OnSync: TAniSyncProc read FOnSync write FOnSync; 54 | property OnDone: TAniDoneProc read FOnDone write FOnDone; 55 | 56 | // Props 57 | property Step: Byte read FStep write FStep default 25; 58 | property AniKind: TAniKind read FAniKind write FAniKind default akIn; 59 | property AniFunctionKind: TAniFunctionKind read FAniFunctionKind write FAniFunctionKind default afkLinear; 60 | 61 | property DelayStartTime: Cardinal read FDelayStartTime write FDelayStartTime default 0; 62 | property Duration: Cardinal read FDuration write FDuration default 400; 63 | property StartValue: Integer read FStartValue write FStartValue default 0; 64 | property DeltaValue: Integer read FDeltaValue write FDeltaValue default 0; 65 | end; 66 | 67 | implementation 68 | 69 | uses 70 | System.Math, 71 | UCL.IntAnimation.Collection; 72 | 73 | { SPECIAL } 74 | 75 | function TIntAni.UpdateFunction: Boolean; 76 | begin 77 | Result := true; 78 | case AniKind of 79 | akIn: 80 | case AniFunctionKind of 81 | afkLinear: 82 | AniFunction := TIntAniCollection.Linear; 83 | afkQuadratic: 84 | AniFunction := TIntAniCollection.Quadratic_In; 85 | afkCubic: 86 | AniFunction := TIntAniCollection.Cubic_In; 87 | afkQuartic: 88 | AniFunction := TIntAniCollection.Quartic_In; 89 | afkQuintic: 90 | AniFunction := TIntAniCollection.Quintic_In; 91 | afkBack: 92 | AniFunction := TIntAniCollection.Back_In; 93 | afkBounce: 94 | AniFunction := TIntAniCollection.Bounce_In; 95 | afkExpo: 96 | AniFunction := TIntAniCollection.Expo_In; 97 | afkSine: 98 | AniFunction := TIntAniCollection.Sine_In; 99 | afkCircle: 100 | AniFunction := TIntAniCollection.Circle_In; 101 | else 102 | Result := false; 103 | end; 104 | 105 | akOut: 106 | case AniFunctionKind of 107 | afkLinear: 108 | AniFunction := TIntAniCollection.Linear; 109 | afkQuadratic: 110 | AniFunction := TIntAniCollection.Quadratic_Out; 111 | afkCubic: 112 | AniFunction := TIntAniCollection.Cubic_Out; 113 | afkQuartic: 114 | AniFunction := TIntAniCollection.Quartic_Out; 115 | afkQuintic: 116 | AniFunction := TIntAniCollection.Quintic_Out; 117 | afkBack: 118 | AniFunction := TIntAniCollection.Back_Out; 119 | afkBounce: 120 | AniFunction := TIntAniCollection.Bounce_Out; 121 | afkExpo: 122 | AniFunction := TIntAniCollection.Expo_Out; 123 | afkSine: 124 | AniFunction := TIntAniCollection.Sine_Out; 125 | afkCircle: 126 | AniFunction := TIntAniCollection.Circle_Out; 127 | else 128 | Result := false; 129 | end; 130 | 131 | akInOut: 132 | case AniFunctionKind of 133 | afkLinear: 134 | AniFunction := TIntAniCollection.Linear; 135 | afkQuadratic: 136 | AniFunction := TIntAniCollection.Quadratic_InOut; 137 | afkCubic: 138 | AniFunction := TIntAniCollection.Cubic_InOut; 139 | afkQuartic: 140 | AniFunction := TIntAniCollection.Quartic_InOut; 141 | afkQuintic: 142 | AniFunction := TIntAniCollection.Quintic_InOut; 143 | afkBack: 144 | AniFunction := TIntAniCollection.Back_InOut; 145 | afkBounce: 146 | AniFunction := TIntAniCollection.Bounce_InOut; 147 | afkExpo: 148 | AniFunction := TIntAniCollection.Expo_InOut; 149 | afkSine: 150 | AniFunction := TIntAniCollection.Sine_InOut; 151 | afkCircle: 152 | AniFunction := TIntAniCollection.Circle_InOut; 153 | else 154 | Result := false; 155 | end; 156 | 157 | else 158 | Result := false; 159 | end; 160 | end; 161 | 162 | { MAIN CLASS } 163 | 164 | constructor TIntAni.Create( 165 | FreeOnFinish: Boolean; 166 | aAniKind: TAniKind; aAniFunctionKind: TAniFunctionKind; 167 | aStartValue, aDeltaValue: Integer; 168 | aSyncProc: TAniSyncProc); 169 | begin 170 | inherited Create(True); 171 | 172 | // Internal 173 | CurrentValue := 0; 174 | AniFunction := nil; 175 | 176 | // New props 177 | FStep := 25; 178 | FAniKind := aAniKind; 179 | FAniFunctionKind := aAniFunctionKind; 180 | 181 | FDelayStartTime := 0; 182 | FDuration := 400; 183 | FStartValue := aStartValue; 184 | FDeltaValue := aDeltaValue; 185 | 186 | FOnDone := nil; 187 | FOnSync := aSyncProc; 188 | 189 | // Old props 190 | FreeOnTerminate := FreeOnFinish; 191 | 192 | UpdateFunction; 193 | end; 194 | 195 | procedure TIntAni.Execute; 196 | var 197 | i: Cardinal; 198 | t, d, TimePerStep: Cardinal; 199 | b, c: Integer; 200 | begin 201 | if UpdateFunction = false then exit; 202 | /// Update easing function 203 | /// Depend on AniKind (In, Out,...) and AniFunctionKind (Linear,...) 204 | /// If Result = false (error found), then exit 205 | 206 | d := Duration; 207 | b := StartValue; 208 | c := DeltaValue; 209 | 210 | // Delay start 211 | Sleep(DelayStartTime); 212 | 213 | // Calc step by FPS 214 | TimePerStep := Round(d / Step); 215 | 216 | // Run 217 | for i := 1 to Step do 218 | begin 219 | t := i * TimePerStep; 220 | CurrentValue := b + Round(c * AniFunction(t / d)); 221 | Synchronize(UpdateControl); 222 | Sleep(TimePerStep); 223 | end; 224 | 225 | // Finish 226 | Synchronize(UpdateControl); 227 | Synchronize(DoneControl); 228 | end; 229 | 230 | { PROCS } 231 | 232 | procedure TIntAni.DoneControl; 233 | begin 234 | if Assigned(FOnDone) then 235 | FOnDone(); 236 | end; 237 | 238 | procedure TIntAni.UpdateControl; 239 | begin 240 | if Assigned(FOnSync) then 241 | FOnSync(CurrentValue); 242 | end; 243 | 244 | end. 245 | -------------------------------------------------------------------------------- /UCL.IntAnimation.Collection.pas: -------------------------------------------------------------------------------- 1 | unit UCL.IntAnimation.Collection; 2 | 3 | interface 4 | 5 | type 6 | TIntAniCollection = class 7 | // Linear 8 | class function Linear(P: Single): Single; inline; 9 | 10 | // Quadratic 11 | class function Quadratic_In(P: Single): Single; inline; 12 | class function Quadratic_Out(P: Single): Single; inline; 13 | class function Quadratic_InOut(P: Single): Single; inline; 14 | 15 | // Cubic 16 | class function Cubic_In(P: Single): Single; inline; 17 | class function Cubic_Out(P: Single): Single; inline; 18 | class function Cubic_InOut(P: Single): Single; inline; 19 | 20 | // Quartic 21 | class function Quartic_In(P: Single): Single; inline; 22 | class function Quartic_Out(P: Single): Single; inline; 23 | class function Quartic_InOut(P: Single): Single; inline; 24 | 25 | // Quintic 26 | class function Quintic_In(P: Single): Single; inline; 27 | class function Quintic_Out(P: Single): Single; inline; 28 | class function Quintic_InOut(P: Single): Single; inline; 29 | 30 | // Back 31 | class function Back_In(P: Single): Single; inline; 32 | class function Back_Out(P: Single): Single; inline; 33 | class function Back_InOut(P: Single): Single; inline; 34 | 35 | // Bounce 36 | class function Bounce_In(P: Single): Single; inline; 37 | class function Bounce_Out(P: Single): Single; inline; 38 | class function Bounce_InOut(P: Single): Single; inline; 39 | 40 | // Expo 41 | class function Expo_In(P: Single): Single; inline; 42 | class function Expo_Out(P: Single): Single; inline; 43 | class function Expo_InOut(P: Single): Single; inline; 44 | 45 | // Sine 46 | class function Sine_In(P: Single): Single; inline; 47 | class function Sine_Out(P: Single): Single; inline; 48 | class function Sine_InOut(P: Single): Single; inline; 49 | 50 | // Circle 51 | class function Circle_In(P: Single): Single; inline; 52 | class function Circle_Out(P: Single): Single; inline; 53 | class function Circle_InOut(P: Single): Single; inline; 54 | end; 55 | 56 | implementation 57 | 58 | uses 59 | System.Math; 60 | 61 | { LINEAR } 62 | 63 | class function TIntAniCollection.Linear(P: Single): Single; 64 | begin 65 | Result := P; 66 | end; 67 | 68 | { QUADRATIC } 69 | 70 | class function TIntAniCollection.Quadratic_In(P: Single): Single; 71 | begin 72 | Result := P * P; 73 | end; 74 | 75 | class function TIntAniCollection.Quadratic_Out(P: Single): Single; 76 | begin 77 | Result := 1 - Quadratic_In(1 - P); 78 | end; 79 | 80 | class function TIntAniCollection.Quadratic_InOut(P: Single): Single; 81 | begin 82 | if P < 0.5 then 83 | Result := 2 * Quadratic_In(P) 84 | else 85 | Result := 1 - 2 * Quadratic_In(P - 1); 86 | end; 87 | 88 | { CUBIC } 89 | 90 | 91 | class function TIntAniCollection.Cubic_In(P: Single): Single; 92 | begin 93 | Result := P * P * P; 94 | end; 95 | 96 | class function TIntAniCollection.Cubic_Out(P: Single): Single; 97 | begin 98 | Result := 1 - Cubic_In(1 - P); 99 | end; 100 | 101 | class function TIntAniCollection.Cubic_InOut(P: Single): Single; 102 | begin 103 | if P < 0.5 then 104 | Result := 4 * Cubic_In(P) 105 | else 106 | Result := 1 + 4 * Cubic_In(P - 1); 107 | end; 108 | 109 | { QUARTIC } 110 | 111 | class function TIntAniCollection.Quartic_In(P: Single): Single; 112 | begin 113 | Result := P * P * P * P; 114 | end; 115 | 116 | class function TIntAniCollection.Quartic_Out(P: Single): Single; 117 | begin 118 | Result := 1 - Quartic_In(1 - P); 119 | end; 120 | 121 | class function TIntAniCollection.Quartic_InOut(P: Single): Single; 122 | begin 123 | if P < 0.5 then 124 | Result := 8 * Quintic_In(P) 125 | else 126 | Result := 1 - 8 * Quartic_In(P - 1); 127 | end; 128 | 129 | { QUINTIC } 130 | 131 | class function TIntAniCollection.Quintic_In(P: Single): Single; 132 | begin 133 | Result := P * P * P * P * P; 134 | end; 135 | 136 | class function TIntAniCollection.Quintic_Out(P: Single): Single; 137 | begin 138 | Result := 1 - Quintic_In(1 - P); 139 | end; 140 | 141 | class function TIntAniCollection.Quintic_InOut(P: Single): Single; 142 | begin 143 | if P < 0.5 then 144 | Result := 16 * Quintic_In(P) 145 | else 146 | Result := 1 + 16 * Quintic_In(P - 1); 147 | end; 148 | 149 | { BACK } 150 | 151 | class function TIntAniCollection.Back_In(P: Single): Single; 152 | var 153 | S: Single; 154 | begin 155 | S := 1.70158; 156 | Result := P * P * (P * (S + 1) - S); 157 | end; 158 | 159 | class function TIntAniCollection.Back_Out(P: Single): Single; 160 | var 161 | S: Single; 162 | begin 163 | P := P - 1; 164 | S := 1.70158; 165 | Result := 1 + P * P * (P * (S + 1) + S); 166 | end; 167 | 168 | class function TIntAniCollection.Back_InOut(P: Single): Single; 169 | var 170 | S: Single; 171 | begin 172 | S := 1.70158; 173 | P := 2 * P; 174 | if P / 2 < 0.5 then 175 | begin 176 | S := S * 1.525; 177 | Result := 0.5 * P * P * (P * (S + 1) - S); 178 | end 179 | else 180 | begin 181 | P := P - 2; 182 | S := S * 1.525; 183 | Result := 1 + 0.5 * P * P * (P * (S + 1) + S); 184 | end; 185 | end; 186 | 187 | { BOUNCE } 188 | 189 | class function TIntAniCollection.Bounce_In(P: Single): Single; 190 | begin 191 | P := 1 - P; 192 | Result := 1 - Bounce_Out(P); 193 | end; 194 | 195 | class function TIntAniCollection.Bounce_Out(P: Single): Single; 196 | begin 197 | if P < 1 / 2.75 then 198 | Result := 7.5625 * P * P 199 | else if P < 2 / 2.72 then 200 | begin 201 | P := P - (1.5 / 2.75); 202 | Result := 0.75 + 7.5625 * P * P; 203 | end 204 | else if P < 2.5 / 2.75 then 205 | begin 206 | P := P - (2.25 / 2.75); 207 | Result := 0.9375 + 7.5625 * P * P; 208 | end 209 | else 210 | begin 211 | P := P - (2.625 / 2.75); 212 | Result := 0.984375 + 7.5625 * P * P; 213 | end; 214 | end; 215 | 216 | class function TIntAniCollection.Bounce_InOut(P: Single): Single; 217 | begin 218 | if P < 0.5 then 219 | Result := 0.5 * Bounce_In(P * 2) 220 | else 221 | Result := 0.5 * (1 + Bounce_Out(2 * P - 1)); 222 | end; 223 | 224 | { EXPO } 225 | 226 | class function TIntAniCollection.Expo_In(P: Single): Single; 227 | begin 228 | Result := Power(2, (10 * (P - 1))); 229 | end; 230 | 231 | class function TIntAniCollection.Expo_Out(P: Single): Single; 232 | begin 233 | Result := 1 - Power(2, (-10 * P)); 234 | end; 235 | 236 | class function TIntAniCollection.Expo_InOut(P: Single): Single; 237 | begin 238 | P := 2 * P; 239 | if P / 2 < 0.5 then 240 | Result := 0.5 * Power(2, (10 * (P - 1))) 241 | else 242 | Result := 0.5 * (2 - Power(2, (-10 * P))); 243 | end; 244 | 245 | { SINE } 246 | 247 | class function TIntAniCollection.Sine_In(P: Single): Single; 248 | begin 249 | Result := 1 - Cos(P * Pi / 2); 250 | end; 251 | 252 | class function TIntAniCollection.Sine_Out(P: Single): Single; 253 | begin 254 | Result := Sin(P * Pi / 2); 255 | end; 256 | 257 | class function TIntAniCollection.Sine_InOut(P: Single): Single; 258 | begin 259 | Result := 0.5 * (1 - Cos(P * Pi)); 260 | end; 261 | 262 | { CIRCLE } 263 | 264 | class function TIntAniCollection.Circle_In(P: Single): Single; 265 | begin 266 | Result := 1 - Sqrt(1 - P * P); 267 | end; 268 | 269 | class function TIntAniCollection.Circle_Out(P: Single): Single; 270 | begin 271 | P := P - 1; 272 | Result := Sqrt(1 - P * P); 273 | end; 274 | 275 | class function TIntAniCollection.Circle_InOut(P: Single): Single; 276 | begin 277 | P := 2 * P; 278 | if P / 2 < 0.5 then 279 | Result := 0.5 * (1 - Sqrt(1 - P * P)) 280 | else 281 | begin 282 | P := P - 2; 283 | Result := 0.5 * (1 + Sqrt(1 - P * P)); 284 | end; 285 | end; 286 | 287 | end. 288 | -------------------------------------------------------------------------------- /Demo.dproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | {35F87E5F-BC7B-4F87-95D5-EF178385803C} 4 | 18.7 5 | VCL 6 | Demo.dpr 7 | True 8 | Debug 9 | Win32 10 | 1 11 | Application 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Cfg_1 34 | true 35 | true 36 | 37 | 38 | true 39 | Base 40 | true 41 | 42 | 43 | true 44 | Cfg_2 45 | true 46 | true 47 | 48 | 49 | .\$(Platform)\$(Config) 50 | .\$(Platform)\$(Config) 51 | false 52 | false 53 | false 54 | false 55 | false 56 | System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) 57 | $(BDS)\bin\delphi_PROJECTICON.ico 58 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png 59 | $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png 60 | Demo 61 | 62 | 63 | DBXSqliteDriver;bindcompdbx;IndyIPCommon;RESTComponents;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;tethering;svnui;UCLPackage;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;FireDAC;vcltouch;vcldb;bindcompfmx;svn;FireDACSqliteDriver;FireDACPgDriver;inetdb;soaprtl;DbxCommonDriver;FireDACIBDriver;fmx;fmxdae;xmlrtl;soapmidas;fmxobj;vclwinx;rtl;DbxClientDriver;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;FireDACCommon;IndyIPClient;bindcompvcl;RESTBackendComponents;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;attabs_package_delphi;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;IndyProtocols;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage) 64 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 65 | Debug 66 | true 67 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 68 | 1033 69 | $(BDS)\bin\default_app.manifest 70 | 71 | 72 | DBXSqliteDriver;bindcompdbx;IndyIPCommon;RESTComponents;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;tethering;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;FireDAC;vcltouch;vcldb;bindcompfmx;FireDACSqliteDriver;FireDACPgDriver;inetdb;soaprtl;DbxCommonDriver;FireDACIBDriver;fmx;fmxdae;xmlrtl;soapmidas;fmxobj;vclwinx;rtl;DbxClientDriver;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;FireDACCommon;IndyIPClient;bindcompvcl;RESTBackendComponents;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;IndyProtocols;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage) 73 | 74 | 75 | DEBUG;$(DCC_Define) 76 | true 77 | false 78 | true 79 | true 80 | true 81 | 82 | 83 | false 84 | true 85 | PerMonitorV2 86 | true 87 | 1033 88 | 89 | 90 | false 91 | RELEASE;$(DCC_Define) 92 | 0 93 | 0 94 | 95 | 96 | true 97 | PerMonitorV2 98 | 99 | 100 | 101 | MainSource 102 | 103 | 104 |
formAnimation
105 | dfm 106 |
107 | 108 | 109 | 110 | 111 | Cfg_2 112 | Base 113 | 114 | 115 | Base 116 | 117 | 118 | Cfg_1 119 | Base 120 | 121 |
122 | 123 | Delphi.Personality.12 124 | Application 125 | 126 | 127 | 128 | Microsoft Office 2000 Sample Automation Server Wrapper Components 129 | Microsoft Office XP Sample Automation Server Wrapper Components 130 | 131 | 132 | Demo.dpr 133 | 134 | 135 | 136 | 137 | 138 | Demo.exe 139 | true 140 | 141 | 142 | 143 | 144 | 1 145 | 146 | 147 | Contents\MacOS 148 | 1 149 | 150 | 151 | 0 152 | 153 | 154 | 155 | 156 | classes 157 | 1 158 | 159 | 160 | 161 | 162 | res\xml 163 | 1 164 | 165 | 166 | 167 | 168 | library\lib\armeabi-v7a 169 | 1 170 | 171 | 172 | 173 | 174 | library\lib\armeabi 175 | 1 176 | 177 | 178 | 179 | 180 | library\lib\mips 181 | 1 182 | 183 | 184 | 185 | 186 | library\lib\armeabi-v7a 187 | 1 188 | 189 | 190 | 191 | 192 | res\drawable 193 | 1 194 | 195 | 196 | 197 | 198 | res\values 199 | 1 200 | 201 | 202 | 203 | 204 | res\values-v21 205 | 1 206 | 207 | 208 | 209 | 210 | res\values 211 | 1 212 | 213 | 214 | 215 | 216 | res\drawable 217 | 1 218 | 219 | 220 | 221 | 222 | res\drawable-xxhdpi 223 | 1 224 | 225 | 226 | 227 | 228 | res\drawable-ldpi 229 | 1 230 | 231 | 232 | 233 | 234 | res\drawable-mdpi 235 | 1 236 | 237 | 238 | 239 | 240 | res\drawable-hdpi 241 | 1 242 | 243 | 244 | 245 | 246 | res\drawable-xhdpi 247 | 1 248 | 249 | 250 | 251 | 252 | res\drawable-mdpi 253 | 1 254 | 255 | 256 | 257 | 258 | res\drawable-hdpi 259 | 1 260 | 261 | 262 | 263 | 264 | res\drawable-xhdpi 265 | 1 266 | 267 | 268 | 269 | 270 | res\drawable-xxhdpi 271 | 1 272 | 273 | 274 | 275 | 276 | res\drawable-xxxhdpi 277 | 1 278 | 279 | 280 | 281 | 282 | res\drawable-small 283 | 1 284 | 285 | 286 | 287 | 288 | res\drawable-normal 289 | 1 290 | 291 | 292 | 293 | 294 | res\drawable-large 295 | 1 296 | 297 | 298 | 299 | 300 | res\drawable-xlarge 301 | 1 302 | 303 | 304 | 305 | 306 | res\values 307 | 1 308 | 309 | 310 | 311 | 312 | 1 313 | 314 | 315 | Contents\MacOS 316 | 1 317 | 318 | 319 | 0 320 | 321 | 322 | 323 | 324 | Contents\MacOS 325 | 1 326 | .framework 327 | 328 | 329 | Contents\MacOS 330 | 1 331 | .framework 332 | 333 | 334 | 0 335 | 336 | 337 | 338 | 339 | 1 340 | .dylib 341 | 342 | 343 | 1 344 | .dylib 345 | 346 | 347 | 1 348 | .dylib 349 | 350 | 351 | Contents\MacOS 352 | 1 353 | .dylib 354 | 355 | 356 | Contents\MacOS 357 | 1 358 | .dylib 359 | 360 | 361 | 0 362 | .dll;.bpl 363 | 364 | 365 | 366 | 367 | 1 368 | .dylib 369 | 370 | 371 | 1 372 | .dylib 373 | 374 | 375 | 1 376 | .dylib 377 | 378 | 379 | Contents\MacOS 380 | 1 381 | .dylib 382 | 383 | 384 | Contents\MacOS 385 | 1 386 | .dylib 387 | 388 | 389 | 0 390 | .bpl 391 | 392 | 393 | 394 | 395 | 0 396 | 397 | 398 | 0 399 | 400 | 401 | 0 402 | 403 | 404 | 0 405 | 406 | 407 | Contents\Resources\StartUp\ 408 | 0 409 | 410 | 411 | Contents\Resources\StartUp\ 412 | 0 413 | 414 | 415 | 0 416 | 417 | 418 | 419 | 420 | 1 421 | 422 | 423 | 1 424 | 425 | 426 | 1 427 | 428 | 429 | 430 | 431 | 1 432 | 433 | 434 | 1 435 | 436 | 437 | 1 438 | 439 | 440 | 441 | 442 | 1 443 | 444 | 445 | 1 446 | 447 | 448 | 1 449 | 450 | 451 | 452 | 453 | 1 454 | 455 | 456 | 1 457 | 458 | 459 | 1 460 | 461 | 462 | 463 | 464 | 1 465 | 466 | 467 | 1 468 | 469 | 470 | 1 471 | 472 | 473 | 474 | 475 | 1 476 | 477 | 478 | 1 479 | 480 | 481 | 1 482 | 483 | 484 | 485 | 486 | 1 487 | 488 | 489 | 1 490 | 491 | 492 | 1 493 | 494 | 495 | 496 | 497 | 1 498 | 499 | 500 | 1 501 | 502 | 503 | 1 504 | 505 | 506 | 507 | 508 | 1 509 | 510 | 511 | 1 512 | 513 | 514 | 1 515 | 516 | 517 | 518 | 519 | 1 520 | 521 | 522 | 1 523 | 524 | 525 | 1 526 | 527 | 528 | 529 | 530 | 1 531 | 532 | 533 | 1 534 | 535 | 536 | 1 537 | 538 | 539 | 540 | 541 | 1 542 | 543 | 544 | 1 545 | 546 | 547 | 1 548 | 549 | 550 | 551 | 552 | 1 553 | 554 | 555 | 1 556 | 557 | 558 | 1 559 | 560 | 561 | 562 | 563 | 1 564 | 565 | 566 | 1 567 | 568 | 569 | 1 570 | 571 | 572 | 573 | 574 | 1 575 | 576 | 577 | 1 578 | 579 | 580 | 1 581 | 582 | 583 | 584 | 585 | 1 586 | 587 | 588 | 1 589 | 590 | 591 | 1 592 | 593 | 594 | 595 | 596 | 1 597 | 598 | 599 | 1 600 | 601 | 602 | 1 603 | 604 | 605 | 606 | 607 | 1 608 | 609 | 610 | 1 611 | 612 | 613 | 1 614 | 615 | 616 | 617 | 618 | 1 619 | 620 | 621 | 1 622 | 623 | 624 | 1 625 | 626 | 627 | 628 | 629 | 1 630 | 631 | 632 | 1 633 | 634 | 635 | 1 636 | 637 | 638 | 639 | 640 | 1 641 | 642 | 643 | 1 644 | 645 | 646 | 1 647 | 648 | 649 | 650 | 651 | 1 652 | 653 | 654 | 1 655 | 656 | 657 | 1 658 | 659 | 660 | 661 | 662 | 1 663 | 664 | 665 | 1 666 | 667 | 668 | 1 669 | 670 | 671 | 672 | 673 | 1 674 | 675 | 676 | 1 677 | 678 | 679 | 1 680 | 681 | 682 | 683 | 684 | 1 685 | 686 | 687 | 688 | 689 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 690 | 1 691 | 692 | 693 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 694 | 1 695 | 696 | 697 | 698 | 699 | 1 700 | 701 | 702 | 1 703 | 704 | 705 | 706 | 707 | ..\ 708 | 1 709 | 710 | 711 | ..\ 712 | 1 713 | 714 | 715 | 716 | 717 | 1 718 | 719 | 720 | 1 721 | 722 | 723 | 1 724 | 725 | 726 | 727 | 728 | 1 729 | 730 | 731 | 1 732 | 733 | 734 | 1 735 | 736 | 737 | 738 | 739 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 740 | 1 741 | 742 | 743 | 744 | 745 | ..\ 746 | 1 747 | 748 | 749 | ..\ 750 | 1 751 | 752 | 753 | 754 | 755 | Contents 756 | 1 757 | 758 | 759 | Contents 760 | 1 761 | 762 | 763 | 764 | 765 | Contents\Resources 766 | 1 767 | 768 | 769 | Contents\Resources 770 | 1 771 | 772 | 773 | 774 | 775 | library\lib\armeabi-v7a 776 | 1 777 | 778 | 779 | 1 780 | 781 | 782 | 1 783 | 784 | 785 | 1 786 | 787 | 788 | 1 789 | 790 | 791 | Contents\MacOS 792 | 1 793 | 794 | 795 | Contents\MacOS 796 | 1 797 | 798 | 799 | 0 800 | 801 | 802 | 803 | 804 | 1 805 | 806 | 807 | 1 808 | 809 | 810 | 811 | 812 | Assets 813 | 1 814 | 815 | 816 | Assets 817 | 1 818 | 819 | 820 | 821 | 822 | Assets 823 | 1 824 | 825 | 826 | Assets 827 | 1 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | True 842 | False 843 | 844 | 845 | 12 846 | 847 | 848 | 849 | 850 |
851 | --------------------------------------------------------------------------------