• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Delphi与DirectX之DelphiX(15):TPictureCollectionItem.DrawWaveX、DrawWaveY...

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

此类函数有:
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.


窗体文件:
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 154
  ClientWidth = 259
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object DXDraw1: TDXDraw
    Left = 8
    Top = 8
    Width = 185
    Height = 121
    AutoInitialize = True
    AutoSize = True
    Color = clBlack
    Display.FixedBitCount = False
    Display.FixedRatio = True
    Display.FixedSize = True
    Options = [doAllowReboot, doWaitVBlank, doCenter, do3D, doDirectX7Mode, doHardware, doSelectDriver]
    SurfaceHeight = 121
    SurfaceWidth = 185
    TabOrder = 0
    Traces = <>
  end
  object Edit1: TEdit
    Left = 212
    Top = 125
    Width = 38
    Height = 21
    TabOrder = 1
    Text = 'Edit1'
    OnChange = Edit1Change
  end
  object CheckBox1: TCheckBox
    Left = 120
    Top = 129
    Width = 86
    Height = 17
    Caption = 'CheckBox1'
    TabOrder = 2
    OnClick = CheckBox1Click
  end
  object DXImageList1: TDXImageList
    Items.ColorTable = {
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000}
    Items = <>
    Left = 224
    Top = 8
  end
  object DXTimer1: TDXTimer
    ActiveOnly = True
    Enabled = True
    Interval = 1000
    OnTimer = DXTimer1Timer
    Left = 224
    Top = 48
  end
end


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
用Delphi实现自定义颜色对话框及其构件发布时间:2022-07-18
下一篇:
Delphi中对BCD码的直接支持.发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap