程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi 的繪圖功能[7] - PolyBezier、PolyBezierTo

Delphi 的繪圖功能[7] - PolyBezier、PolyBezierTo

編輯:Delphi

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 至少需要四個點做參數; 不改變畫筆的當前位置}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 最少只需要需要三個點, 它把當前位置當作第一點; 會改變畫筆的當前位置}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.
//效果圖:

Delphi 的繪圖功能[7] - PolyBezier、PolyBezierTo

  //繪制多條貝塞爾線時, 每條線的終點也是下條線的起點.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 繪制多條線時, 需要 3*x + 1 個點}procedure TForm1.Button1Click(Sender: TObject);
var
 pts: array[0..6] 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;
 pts[2].X := 10; pts[2].Y := 100;
 pts[3].X := 40; pts[3].Y := 100;
 pts[4].X := 100; pts[4].Y := 10;
 pts[5].X := 55; pts[5].Y := 99;
 pts[6].X := 70; pts[6].Y := 10;
 Canvas.PolyBezIEr(pts);
end;
{PolyBezIErTo 繪制多條線時, 需要 3*x 個點}procedure TForm1.Button2Click(Sender: TObject);
var
 pts: array[1..6] of TPoint;
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;
 pts[2].X := 10 + 82; pts[2].Y := 100;
 pts[3].X := 40 + 82; pts[3].Y := 100;
 pts[4].X := 100 + 82; pts[4].Y := 10;
 pts[5].X := 55 + 82; pts[5].Y := 99;
 pts[6].X := 70 + 82; pts[6].Y := 10;
 Canvas.PolyBezIErTo(pts);
end;
end.
//效果圖:

Delphi 的繪圖功能[7] - PolyBezier、PolyBezierTo


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved