Delphi与DirectX之DelphiX(15)

此类函数有:
TPictureCollectionItem.DrawWaveX();
TPictureCollectionItem.DrawWaveXAdd();
TPictureCollectionItem.DrawWaveXAlpha();
TPictureCollectionItem.DrawWaveXSub();
TPictureCollectionItem.DrawWaveY();
TPictureCollectionItem.DrawWaveYAdd();
TPictureCollectionItem.DrawWaveYAlpha();
TPictureCollectionItem.DrawWaveYSub();

本例仅使用了 DrawWaveX、DrawWaveY, 效果图:


代码文件:

unit Unit1;
interface
uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, DXDraws, StdCtrls, DXClass;
type
 TForm1 = class(TForm)
  DXDraw1: TDXDraw;
  DXImageList1: TDXImageList;
  DXTimer1: TDXTimer;
  Edit1: TEdit;
  CheckBox1: TCheckBox;
  procedure FormCreate(Sender: TObject);
  procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);
  procedure Edit1Change(Sender: TObject);
  procedure CheckBox1Click(Sender: TObject);
 end;
var
 Form1: TForm1;
implementation
{$R *.dfm}
const
 arr: array[0..31] of Smallint =
  (-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,7,6,5,4,3,2,-1,0,-1,-2,-3,-4,-5,-6,-7);
var
 PicItem: TPictureCollectionItem;
 amp,len: Integer;
procedure TForm1.Edit1Change(Sender: TObject);
begin
 len := StrToIntDef(Edit1.Text, 0);
end;
procedure TForm1.FormCreate(Sender: TObject);
const
 ImgPath1 = 'C:\Temp\DelphiX.bmp';
begin
 DXImageList1.DXDraw := DXDraw1;
 PicItem := TPictureCollectionItem(DXImageList1.Items.Add);
 PicItem.Picture.LoadFromFile(ImgPath1);
 DXDraw1.Align := alClient;
 DXTimer1.Interval := 30;
 Edit1.Text := '60';
 Edit1Change(nil);
 CheckBox1.Checked := True;
 CheckBox1.Caption := 'DrawWaveX';
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
const
 bs: array[Boolean] of string = ('DrawWaveY', 'DrawWaveX');
begin
 CheckBox1.Caption := bs[CheckBox1.Checked];
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
 DXDraw1.Surface.Fill(0);
 if CheckBox1.Checked then
  PicItem.DrawWaveX(DXDraw1.Surface,
           (DXDraw1.Width - PicItem.Width) div 2, (DXDraw1.Height - PicItem.Height) div 2,
            PicItem.Width, PicItem.Height,
            0,
            arr[amp and 31],
            len,
            0)
  else
   PicItem.DrawWaveY(DXDraw1.Surface,
           (DXDraw1.Width - PicItem.Width) div 2, (DXDraw1.Height - PicItem.Height) div 2,
            PicItem.Width, PicItem.Height,
            0,
           arr[amp and 31],
           len,
           0);
 DXDraw1.Flip;
 Inc(amp);
end;
end.

时间: 2024-10-30 15:33:31

Delphi与DirectX之DelphiX(15)的相关文章

Delphi与DirectX之DelphiX(87): TDIB.DrawTransparent、DrawTranslucent、Dra

Delphi与DirectX之DelphiX(87): TDIB.DrawTransparent.DrawTranslucent.DrawAlpha(); TDIB.DrawTransparent: 按指定的透明色透明; TDIB.DrawTranslucent: 先按指定的透明色透明, 然后再半透明; DIB.DrawAlpha: 先按指定的透明色透明, 再按指定的透明度透明. 本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages,

Delphi与DirectX之DelphiX(17):TPictureCollectionItem.PatternWidth、Patte

Delphi与DirectX之DelphiX(17):TPictureCollectionItem.PatternWidth.PatternHeight 本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, StdCtrls; type TForm1 = class(TForm) DXD

Delphi与DirectX之DelphiX(7)

Delphi与DirectX 之DelphiX(7): 给TDXImageList加载图片的最后方案 本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, StdCtrls; type TForm1 = class(TForm) DXDraw1: TDXDraw; DXImageList

Delphi与DirectX之DelphiX(6)

Delphi与DirectX之DelphiX(6): 让TDXImageList和常规VCL交互使用 本例测试了两个问题: 1.其他 VCL 加载的图片能否给 TDXImageList 使用; 2.TDXImageList 中的图片能否给其他 VCL 使用. 例子中先用 TPicture 加载了图片, 然后给 TDXImageList; 然后把图片绘制在了窗体上, 而非 TDXDraw 中. 继续了解点 TDXImageList: TDXImageList 控件只有两个属性: DXDraw 和

Delphi与DirectX之DelphiX(1):安装测试

测试 Demo 下载: files.cnblogs.com/del/DelphiX_1.rar (在 Delphi 2007 和 2009 下均编译通过) 其实按照这里(www.cnblogs.com/del/archive/2008/06/13/1219324.html)的介绍, 比下载来的快, 也不需要下载. DirectX, 微软很久的技术了; 从 Windows Vista 开始, DirectX 已经是微软操作系统的界面基础了. 在 Delphi 下使用 DirectX 比较流行的有下

Delphi与DirectX之DelphiX(3):初识TDXDraw

在 DelphiX 中, 所能看到的一般都是画在 TDXDraw. TDXDraw 默认两个绘图表面: TDXDraw.Surface 和 TDXDraw.Primary; 一般先在后台(Surface)绘图, 然后再用 TDXDraw.Flip 命令切换前后台, 从而看到绘制效果. TDXDraw.Flip 会置换 Surface 和 Primary 两个对象, 所以我们尽可以只在 Surface 上绘图; 由于 DirectX 的工作机制, 让这个切换速度异常地快(只是切换一个指针), 从而

Delphi与DirectX之DelphiX(24):TDirectDrawSurface.Blt()、BltFast();

这两个函数可不是一般的麻烦, 特别是Blt(); 暂时搞不彻底, 这是初步尝试的例子: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, StdCtrls, DirectX; type TForm1 = class(TForm) DXDraw1: TDXDraw; Button1: TButton

Delphi与DirectX之DelphiX(8) 第一个简单动画

本例效果图(用 gif 动画演示, 无论如何也出不来 DirectX 的流畅效果): 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, StdCtrls, DXClass; type TForm1 = class(TForm) DXDraw1: TDXDraw; DXImageList1: TDX

Delphi与DirectX之DelphiX(91): TDIB.DrawMono();

本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DIB, StdCtrls; type TForm1 = class(TForm) DXPaintBox1: TDXPaintBox; Button1: TButton; procedure Button1Click(Sender: TObject);