Delphi GDI + learning record (1) brushes

Source: Internet
Author: User

Brush

var
 g: TGPGraphics;
 p: TGPPen;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 p := TGPPen.Create(aclRed, 2);
 {参数1颜色; 参数2是笔宽, 笔宽是可选, 默认 1}
 g.DrawEllipse(p, 11, 11, 222, 111);
 p.Free;
 g.Free;
end;

Set pen width and color

var
 g: TGPGraphics;
 p: TGPPen;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 p := TGPPen.Create(aclBlack);
 {建立时应该不给参数是可以的, 但在测试中不行, 至少要给一个颜色}
 p.SetColor(aclBlue); {设置颜色}
 p.SetWidth(10);   {设置笔宽}
 g.DrawEllipse(p, 11, 11, 222, 111);
 p.Free;
 g.Free;
end;

Get pen width and color

var
 g: TGPGraphics;
 p: TGPPen;
 c: TGPColor;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 p := TGPPen.Create(MakeColor(128,0,0,255), 10);
 g.DrawEllipse(p, 11, 11, 222, 111);
 p.GetColor(c);            {获取颜色给 c}
 ShowMessage(IntToHex(c, 8));     {转换为十六进制: 800000FF}
 ShowMessage(FloatToStr(p.GetWidth)); {10}
 p.Free;
 g.Free;
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.