Delphi's Drawing function [7]

Source: Internet
Author: User
Tags requires

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.