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


此类函数有:
 
 
 
 
 

 

 
  
TPictureCollectionItem.DrawWaveX();
TPictureCollectionItem.DrawWaveXAdd();
TPictureCollectionItem.DrawWaveXAlpha();
TPictureCollectionItem.DrawWaveXSub();
TPictureCollectionItem.DrawWaveY();
TPictureCollectionItem.DrawWaveYAdd();
TPictureCollectionItem.DrawWaveYAlpha();
TPictureCollectionItem.DrawWaveYSub();
 
 
 
 
 

 

 
  

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

Delphi 与 DirectX 之 DelphiX(15): TPictureCollectionItem.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

 
 
 
 
 

 

 
  

你可能感兴趣的:(Delphi 与 DirectX 之 DelphiX(15): TPictureCollectionItem.DrawWaveX、DrawWaveY ...)