欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

再学 GDI+[2]: DrawLine - 绘制直线

程序员文章站 2022-03-31 11:29:07
...

 

unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}
uses
  GDIPAPI,GDIPOBJ;
procedure TForm1.FormPaint(Sender: TObject);
var
  g:TGPGraphics;
  p:TGPPen;
begin
  g:=TGPGraphics.Create(Canvas.Handle);
  g.Clear(aclWhite);
  p:=TGPPen.Create(aclRed,2);

  g.DrawLine(p,20, 40, 200, 40);
  g.DrawLine(p,MakePoint(20,60), MakePoint(200,60));  {参数是点(整数)}
  g.DrawLine(p,20.9, 80.0, 200.9, 80.0);       {参数是小数}
  g.DrawLine(p,MakePoint(20.9, 100.0), MakePoint(200.9, 100.0)); {参数是点(小数)}

  p.Free;
  g.Free;
end;

end.

转载于:https://www.cnblogs.com/keyvip/archive/2010/12/31/1922781.html