关于流动线的问题!(200分)

  • 主题发起人 主题发起人 hawkview
  • 开始时间 开始时间
H

hawkview

Unregistered / Unconfirmed
GUEST, unregistred user!
实现任意两点间画线,线绿白相间,流动且线宽比较宽,我看过关于流动线的帖子,但实现的线宽为1,不满足我的要求,不知各位大虾有何妙法?谢谢。
 
下面的代码是在“卷起千堆雪tyn”在ID:930660中发布的代码中修改而成。

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;

type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;
Counter :Byte;

implementation

{$R *.DFM}

procedure MovingDots(X,Y: Integer; TheCanvas: TCanvas); stdcall;
var
r:TRect;
begin
r.Left:=x-1;
r.Right:=x+1;
r.Top:=y-1;
r.Bottom:=y+1;

Counter := Counter shl 1; // Shift the bit left one
if Counter = 0 then Counter := 1; // If it shifts off left, reset it
if (Counter and 224) > 0 then // Are any of the left 3 bits set?
begin
//TheCanvas.Pixels[X,Y] :=clBtnFace // Erase the pixel
TheCanvas.Brush.Color:=clBtnFace;
TheCanvas.FillRect(r);
end
else
begin
//TheCanvas.Pixels[X,Y] :=clBlack; // Draw the pixel
TheCanvas.Brush.Color:=clGreen;
TheCanvas.FillRect(r);
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
LineDDA(30,30,200,30,@MovingDots,LongInt(Canvas));
LineDDA(200,30,200,150,@MovingDots,LongInt(Canvas));
LineDDA(200,150,30,150,@MovingDots,LongInt(Canvas));
LineDDA(30,150,30,30,@MovingDots,LongInt(Canvas));
end;

end.
 
我主要是想画线,你的这种方法我也想过,但都有一个问题,就是填充TRect,画水平和垂直线时没问题,画斜线时有严重变形,还请继续探讨。
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
849
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部