?? lineddaunit.pas
字號:
unit LineDDAUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
{the callback function prototype}
procedure AnimLines(X, Y: Integer; lpData: lParam); stdcall;
var
Form1: TForm1;
Offset: Integer;
const
AL_HORIZONTAL = 1; // indicates if the line to be drawn is
AL_VERTICAL = 2; // horizontal or vertical
implementation
{$R *.DFM}
procedure AnimLines(X, Y: Integer; lpData: lParam);
var
Coord: Integer; // holds the coordinate used in the calculation
begin
{if the line is horizontal, use the X coordinate, otherwise use Y}
if lpData=AL_HORIZONTAL then
Coord := X
else
Coord := Y;
{determine if the pixel at this point should be black or white}
if (Coord mod 5=Offset) then
SetPixelV(Form1.Canvas.Handle, X, Y, clBlack)
else
SetPixelV(Form1.Canvas.Handle, X, Y, clWhite);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
{increment the offset}
Inc(Offset);
{if the offset has gone too far, reset it}
if Offset>4 then Offset := 0;
{draw a rectangle with animated lines}
LineDDA(20, 20, 120, 20, @AnimLines, AL_HORIZONTAL);
LineDDA(120, 20, 120, 120, @AnimLines, AL_VERTICAL);
LineDDA(20, 20, 20, 120, @AnimLines, AL_VERTICAL);
LineDDA(20, 120, 120, 120, @AnimLines, AL_HORIZONTAL);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -