在这里演示:snorkl.tv
解决方法 像这样的东西可能会产生类似的效果(只是另一种尝试,以显示如何做到这一点,也不是那么精确,但它只是为了好玩,因为你已经要求一个库或组件).该原理基于一个rectnagle,它正在调整大小并居中在绘图框中,其中使用StretchDraw函数渲染卡片:Unit1.pas
unit Unit1;interfaceuses windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls,ExtCtrls,PNGImage;type TCardSIDe = (csBack,csFront); TForm1 = class(TForm) Timer1: TTimer; Timer2: TTimer; PaintBox1: TPaintBox; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Timer2Timer(Sender: TObject); procedure PaintBox1Click(Sender: TObject); procedure PaintBox1Paint(Sender: TObject); private FCardRect: TRect; FCardSIDe: TCardSIDe; FCardBack: TPNGImage; FCardFront: TPNGImage; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin FCardSIDe := csBack; FCardRect := PaintBox1.ClIEntRect; FCardBack := TPNGImage.Create; FCardBack.LoadFrom@R_419_6852@('tps2N.png'); FCardFront := TPNGImage.Create; FCardFront.LoadFrom@R_419_6852@('Ey3cv.png');end;procedure TForm1.FormDestroy(Sender: TObject);begin FCardBack.Free; FCardFront.Free;end;procedure TForm1.Timer1Timer(Sender: TObject);begin if FCardRect.Right - FCardRect.left > 0 then begin FCardRect.left := FCardRect.left + 3; FCardRect.Right := FCardRect.Right - 3; PaintBox1.InvalIDate; end else begin Timer1.Enabled := False; case FCardSIDe of csBack: FCardSIDe := csFront; csFront: FCardSIDe := csBack; end; Timer2.Enabled := True; end;end;procedure TForm1.Timer2Timer(Sender: TObject);begin if FCardRect.Right - FCardRect.left < PaintBox1.ClIEntWIDth then begin FCardRect.left := FCardRect.left - 3; FCardRect.Right := FCardRect.Right + 3; PaintBox1.InvalIDate; end else Timer2.Enabled := False;end;procedure TForm1.PaintBox1Click(Sender: TObject);begin Timer1.Enabled := False; Timer2.Enabled := False; FCardRect := PaintBox1.ClIEntRect; Timer1.Enabled := True; PaintBox1.InvalIDate;end;procedure TForm1.PaintBox1Paint(Sender: TObject);begin case FCardSIDe of csBack: PaintBox1.Canvas.StretchDraw(FCardRect,FCardBack); csFront: PaintBox1.Canvas.StretchDraw(FCardRect,FCardFront); end;end;end.
Unit1.dfm
object Form1: TForm1 left = 0 top = 0 Caption = 'Form1' ClIEntHeight = 203 ClIEntWIDth = 173 color = clBtnFace DoubleBuffered = True Font.Charset = DEFAulT_CHARSET Font.color = clWindowText Font.Height = -11 Font.name = 'Tahoma' Font.Style = [] oldCreateOrder = False position = poScreenCenter OnCreate = FormCreate OnDestroy = FormDestroy PixelsPerInch = 96 TextHeight = 13 object PaintBox1: TPaintBox left = 48 top = 40 WIDth = 77 Height = 121 OnClick = PaintBox1Click OnPaint = PaintBox1Paint end object Timer1: TTimer Enabled = False Interval = 10 OnTimer = Timer1Timer left = 32 top = 88 end object Timer2: TTimer Enabled = False Interval = 10 OnTimer = Timer2Timer left = 88 top = 88 endend
牌
总结以上是内存溢出为你收集整理的图像 – 扑克牌翻转动画全部内容,希望文章能够帮你解决图像 – 扑克牌翻转动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)