Delphi's Drawing function [2]

Source: Internet
Author: User

Drawings need to have paper, brush, brush; Delphi has Canvas, Pen, Brush.

Canvas is the canvas, such as the Canvas property of the form, the canvas of the form;

Pen is a brush, you can set pen color, pen width, and so on;

Brush is a brush, you can set color and so on.

Example: {Draw a line}

procedure TForm1.Button1Click(Sender: TObject);
begin
 Canvas.Pen.Color := clRed; {设置画笔颜色}
 Canvas.Pen.Width := 2;   {设置画笔宽度}
 Canvas.MoveTo(10,10);   {直线起点}
 Canvas.LineTo(100,100);  {直线终点}
{这里的 Canvas 是简写, 也可以写做: Self.Canvas 或 Form1.Canvas }
end;

{Rectangular Fill}

procedure TForm1.Button2Click(Sender: TObject);
begin
 Canvas.Brush.Color := clYellow; {设置画刷颜色, 也就是填充色}
 Canvas.FillRect(ClientRect);  {填充窗体客户区}
end;

Effect Chart:

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.