Re-learning gdi+[64]: Path brushes (4)

Source: Internet
Author: User

In this case, the Centercolor is not specified, and white is the default;

Surroundcolors is the point in the corresponding path (but does not work in the ellipse in the following way).

This example effect chart:

Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs;
Type
TForm1 = Class (Tform)
Procedure Formpaint (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Procedure Tform1.formpaint (Sender:tobject);
Const
COLORARR:ARRAY[0..3] of Tgpcolor = ($FFFF 0000, $FF 00ff00, $FF 0000FF, $FFFFFF 00);
Var
Rt:trect;
Pts:array of Tgppoint;
G:tgpgraphics;
Path1, Path2:tgpgraphicspath;
Pb1,pb2:tgppathgradientbrush;
Num:integer;
Begin
RT: = Bounds (10, 10, 150, 150);
G: = Tgpgraphics.create (Canvas.handle);
{Rectangular Path}
path1: = tgpgraphicspath.create;
Path1. AddRectangle (Makerect (RT));
PB1: = Tgppathgradientbrush.create (path1);
num: = 4;
PB1. Setsurroundcolors (Pargb (@ColorArr), num);
G.fillpath (PB1, path1);
{Triangle Path}
Offsetrect (RT, 160, 0);
SetLength (pts, 3);
Pts[0]: = Makepoint (Rt. Left + (Rt. Right-rt.left) Div 2, Rt. top);
PTS[1]: = Makepoint (Rt. Left, Rt. Bottom);
PTS[2]: = Tgppoint (Rt. BottomRight);
path2: = tgpgraphicspath.create;
Path2. Addpolygon (Pgppoint (pts), Length (pts));
PB2: = Tgppathgradientbrush.create (path2);
num: = 3;
Pb2. Setsurroundcolors (Pargb (@ColorArr), num);
G.fillpath (PB2, path2);
PB1. Free;
Pb2. Free;
Path1. Free;
Path2. Free;
G.free;
End
End.

Form file:object Form1: TForm1
 Left = 0
 Top = 0
 Caption = 'Form1'
 ClientHeight = 172
 ClientWidth = 327
 Color = clBtnFace
 Font.Charset = DEFAULT_CHARSET
 Font.Color = clWindowText
 Font.Height = -11
 Font.Name = 'Tahoma'
 Font.Style = []
 OldCreateOrder = False
 Position = poDesktopCenter
 OnPaint = FormPaint
 PixelsPerInch = 96
 TextHeight = 13
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.