📄 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 + -