Re-learning gdi+[70]: Path Brushes (10)

Source: Internet
Author: User
Tags min

This example effect chart:

Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Comctrls, Stdctrls, Extctrls;
Type
TForm1 = Class (Tform)
Trackbar1:ttrackbar;
Trackbar2:ttrackbar;
Trackbar3:ttrackbar;
Trackbar4:ttrackbar;
Trackbar5:ttrackbar;
Trackbar6:ttrackbar;
Procedure Formpaint (Sender:tobject);
Procedure Formcreate (Sender:tobject);
Procedure Trackbar1change (Sender:tobject);
Procedure Trackbar2change (Sender:tobject);
Procedure Trackbar3change (Sender:tobject);
Procedure Trackbar4change (Sender:tobject);
Procedure Trackbar5change (Sender:tobject);
Procedure Trackbar6change (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Procedure Tform1.formcreate (Sender:tobject);
Begin
Trackbar1.max: = 10;
Trackbar2.max: = 10;
Trackbar3.max: = 10;
Trackbar4.max: = 10;
Trackbar5.max: = 10;
Trackbar6.max: = 10;
Trackbar1.position: = Trackbar1.max;
Trackbar2.position: = Trackbar2.min;
Trackbar3.position: = Trackbar3.max;
Trackbar4.position: = Trackbar4.min;
Trackbar5.position: = Trackbar5.max Div 2;
Trackbar6.position: = Trackbar6.max;
End
Procedure Tform1.formpaint (Sender:tobject);
Const
PTS:ARRAY[0..2] of tgppoint = (x:120; Y:10), (x:40; y:140), (x:200; y:140));
COLORS:ARRAY[0..2] of Tgpcolor = (aclred, Aclgreen, Aclyellow);
Var
G:tgpgraphics;
Path:tgpgraphicspath;
Pb:tgppathgradientbrush;
BLENDFACTORS:ARRAY[0..2] of single;
POS:ARRAY[0..2] of single;
Num:integer;
Begin
G: = Tgpgraphics.create (Canvas.handle);
Path: = Tgpgraphicspath.create;
Path. Addpolygon (Pgppoint (@pts), Length (pts));
PB: = tgppathgradientbrush.create (path);
Num: = Length (colors);
Pb. Setsurroundcolors (@colors, num); {Setblend is only valid when setting surround color}
Blendfactors[0]: = TRACKBAR1.POSITION/10;
BLENDFACTORS[1]: = TRACKBAR2.POSITION/10;
BLENDFACTORS[2]: = TRACKBAR3.POSITION/10;
Pos[0]: = TRACKBAR4.POSITION/10;
POS[1]: = TRACKBAR5.POSITION/10;
POS[2]: = TRACKBAR6.POSITION/10;
Pb. Setblend (@blendFactors, Psingle (@pos), Length (blendfactors));
G.fillpath (Pb, Path);
Pb. Free;
Path. Free;
G.free;
End
Procedure Tform1.trackbar1change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar2change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar3change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar4change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar5change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar6change (Sender:tobject);
Begin
Repaint;
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.