程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi與DirectX之DelphiX(21):TDirectDrawSurface的繪圖命令

Delphi與DirectX之DelphiX(21):TDirectDrawSurface的繪圖命令

編輯:Delphi

TDirectDrawSurface.PokeLine();
TDirectDrawSurface.PokeLinePolar();
TDirectDrawSurface.PokeBox();
TDirectDrawSurface.PokeBlendPixel();
TDirectDrawSurface.PokeCircle();
TDirectDrawSurface.PokeEllipse();
TDirectDrawSurface.PokeFilledEllipse();
TDirectDrawSurface.PokeWuLine();
TDirectDrawSurface.PokeVLine();
TDirectDrawSurface.DoRotate();

這些繪圖命令都需要在TDirectDrawSurface.Lock和TDirectDrawSurface.UnLock之間進行, 並不是特別好用.

另外還有兩個讀寫屬性: Pixel和Pixels, 繪制時前者須在Lock、UnLock之間, 後者又不能鎖定, 真是不完善.

本例只是個畫線的例子, 運行效果圖:

代碼文件:

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DXClass, DXDraws;
type
TForm1 = class(TForm)
DXDraw1: TDXDraw;
DXTimer1: TDXTimer;
procedure FormCreate(Sender: TObject);
procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
DXDraw1.Align := alClient;
DXTimer1.Interval := 50;
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
var
x1,y1,x2,y2: Integer;
clr: TColor;
begin
x1 := Random(DXDraw1.Surface.Width);
y1 := Random(DXDraw1.Surface.Height);
x2 := Random(DXDraw1.Surface.Width);
y2 := Random(DXDraw1.Surface.Height);
clr := Random($FFFFFF);
// DXDraw1.Surface.Fill(0);
DXDraw1.Surface.Lock;
DXDraw1.Surface.PokeLine(x1, y1, x2, y2, clr);
DXDraw1.Surface.UnLock;
DXDraw1.Flip;
end;
end.

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved