unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{Polybezier requires at least four points to make the argument; do not change the brush's current position}procedure TForm1.Button1Click(Sender: TObject);
var
pts: array[0..3] of TPoint;
begin
Canvas.Pen.Width := 2;
Canvas.Pen.Color := clRed;
pts[0].X := 10; pts[0].Y := 10; {起点}
pts[1].X := 60; pts[1].Y := 10; {控制点1}
pts[2].X := 10; pts[2].Y := 100; {控制点2}
pts[3].X := 60; pts[3].Y := 100; {终点}
Canvas.PolyBezier(pts);
Canvas.Pen.Width := 1;
Canvas.Pen.Color := clWhite;
Canvas.LineTo(ClientWidth, ClientHeight);
end;
{PolyBezierTo requires at least three points, it takes the current position as 1th; changes the current position of the brush}procedure TForm1.Button2Click(Sender: TObject);
var
pts: array[1..3] of TPoint; {从 1 开始的, 就 3 个元素}
begin
Canvas.Pen.Width := 2;
Canvas.Pen.Color := clRed;
Canvas.MoveTo(10 + 82, 10); {起点}
//pts[0].X := 10; pts[0].Y := 10;
pts[1].X := 60 + 82; pts[1].Y := 10; {控制点1}
pts[2].X := 10 + 82; pts[2].Y := 100; {控制点2}
pts[3].X := 60 + 82; pts[3].Y := 100; {终点}
Canvas.PolyBezierTo(pts);
Canvas.Pen.Width := 1;
Canvas.Pen.Color := clBlue;
Canvas.LineTo(ClientWidth, ClientHeight);
end;
end.