|
Oct
12
|
Le code source de cette fiche :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | unit main; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Objects, FMX.Filter.Effects, FMX.Ani; type TfrmMain = class(TForm) imgBelly : TImage; txtEffect : TText; effRipple : TRippleEffect; effSmoothMagnify : TSmoothMagnifyEffect; effPinch : TPinchEffect; effWave : TWaveEffect; effHueAdjust : THueAdjustEffect; effTransitionRipple: TRippleTransitionEffect; procedure FormCreate(Sender: TObject); procedure imgBellyMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); procedure imgBellyDblClick(Sender: TObject); private procedure DisableEffects; procedure DoEffect(X, Y: Single); { Private declarations } public { Public declarations } end; var frmMain: TfrmMain; implementation {$R *.fmx} procedure TfrmMain.DisableEffects; var iLoop, iMax: Integer; begin iMax := Pred(imgBelly.ChildrenCount); for iLoop := 0 to iMax do begin if (imgBelly.Children[iLoop] is TImageFXEffect) then begin (imgBelly.Children[iLoop] as TImageFXEffect).Enabled := False; end; end; end; procedure TfrmMain.DoEffect(X, Y: Single); var bmp: TBitmap; begin case Tag of 0: begin effRipple.Center := PointF(X, Y); effRipple.Phase := 20; effRipple.Amplitude := 1; effRipple.Enabled := True; effRipple.AnimateFloat('Phase', 0, 1.5); effRipple.AnimateFloat('Amplitude', 0.3, 0.5); effRipple.AnimateFloatDelay('Amplitude', 0, 1, 0.5); end; 1: begin effSmoothMagnify.Center := PointF(X, Y); effSmoothMagnify.Magnification := 1; effSmoothMagnify.Enabled := True; effSmoothMagnify.AnimateFloat('Magnification', 3, 1, TAnimationType.atInOut, TInterpolationType.itBounce); effSmoothMagnify.AnimateFloatDelay('Magnification', 1, 1, 1); end; 2: begin effPinch.Center := PointF(X, Y); effPinch.Radius := 0; effPinch.Enabled := True; effPinch.AnimateFloat('Radius', 0.5, 1, TAnimationType.atInOut, TInterpolationType.itElastic); effPinch.AnimateFloatDelay('Radius', 0, 1, 1); end; 3: begin effWave.WaveSize := 256; effWave.Enabled := True; effWave.AnimateFloatWait('WaveSize', 32, 2, TAnimationType.atInOut, TInterpolationType.itSinusoidal); effWave.Enabled := False; end; 4: begin effHueAdjust.Hue := 0; effHueAdjust.Enabled := True; effHueAdjust.AnimateFloat('Hue', 1, 1); effHueAdjust.AnimateFloatDelay('Hue', -1, 2, 1); effHueAdjust.AnimateFloatDelay('Hue', 0, 1, 3); end; 5: begin effTransitionRipple.Progress := 0; effTransitionRipple.Enabled := True; effTransitionRipple.AnimateFloatWait('Progress', 100, 3); bmp := TBitmap.Create(imgBelly.Bitmap.Width, imgBelly.Bitmap.Height); try bmp.Assign(imgBelly.Bitmap); imgBelly.Bitmap.Assign(effTransitionRipple.Target); effTransitionRipple.Target.Assign(bmp); finally bmp.Free; end; effTransitionRipple.Enabled := False; end; end; end; procedure TfrmMain.FormCreate(Sender: TObject); begin DisableEffects; txtEffect.AnimateFloat('Opacity', 0, 2); end; procedure TfrmMain.imgBellyDblClick(Sender: TObject); begin Close; end; procedure TfrmMain.imgBellyMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); begin case Button of TMouseButton.mbLeft: DoEffect(X, Y); TMouseButton.mbRight: begin Tag := Tag + 1; case Tag of 1: Caption := 'SmoothMagnify'; 2: Caption := 'Pinch'; 3: Caption := 'Wave'; 4: Caption := 'Hue'; 5: Caption := 'RippleTransition'; else begin Caption := 'Ripple'; Tag := 0; DisableEffects; end; end; txtEffect.Text := Caption; txtEffect.AnimateFloat('Opacity', 1, 1); txtEffect.AnimateFloatDelay('Opacity', 0, 1, 1); end; end; end; end. |
Merci à Thierry pour la relecture du code et ses remarques pertinentes
Développé avec Embarcadero Delphi XE2.




Derniers commentaires