zoukankan      html  css  js  c++  java
  • Delphi 与 DirectX 之 DelphiX(21): TDirectDrawSurface 的绘图命令


    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.
    

  • 相关阅读:
    js中return的作用
    jstl标签详解总结
    css——overflow属性用法
    oracle数据批处理
    SQL Server 2000/2005 分页SQL — 单条SQL语句
    dataset和实体类 之间的转换
    barmanager设置
    C#集合类(HashTable, Dictionary, ArrayList)与HashTable线程安全
    comboboxEdit 不能输入,只能选择
    C#在父窗口中调用子窗口的过程(无法访问已释放的对象)
  • 原文地址:https://www.cnblogs.com/del/p/1376547.html
Copyright © 2011-2022 走看看