Re-learning gdi+[63]: Path brushes (3)

Source: Internet
Author: User

This example effect chart:

Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, Checklst, Extctrls, Tecanvas, Comctrls;
Type
TForm1 = Class (Tform)
Trackbar1:ttrackbar;
Trackbar2:ttrackbar;
Procedure Formcreate (Sender:tobject);
Procedure Formdestroy (Sender:tobject);
Procedure Formpaint (Sender:tobject);
Procedure Trackbar1change (Sender:tobject);
Procedure Trackbar2change (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Var
Rect:tgprect;
Pb:tgppathgradientbrush;
Procedure Tform1.formcreate (Sender:tobject);
Var
Path:tgpgraphicspath;
Colorsurround:tgpcolor;
Num:integer;
Begin
Rect: = Makerect (Ten, ClientWidth-40, ClientHeight-40);
Path: = Tgpgraphicspath.create;
Path. AddEllipse (rect);
PB: = tgppathgradientbrush.create (path);
Pb. Setcentercolor (Acllime);
Colorsurround: = Aclblack;
num: = 1;
Pb. Setsurroundcolors (@ColorSurround, num);
Path. Free;
DoubleBuffered: = True;
Trackbar1.max: = 100;
Trackbar2.max: = 100;
End
Procedure Tform1.formdestroy (Sender:tobject);
Begin
Pb. Free;
End
Procedure Tform1.formpaint (Sender:tobject);
Var
G:tgpgraphics;
P:tgppen;
X,y:single;
Begin
G: = Tgpgraphics.create (Canvas.handle);
P: = tgppen.create (aclred);
G.fillellipse (Pb, Rect);
Pb. Setcenterpoint (Makepoint) (rect. X + rect. Width Div 2, rect. Y + rect. Height Div 2));
{Setfocusscales}
Pb. Setfocusscales (trackbar1.position/100, trackbar2.position/100);
{Getfocusscales}
Pb. Getfocusscales (x, y);
Text: = Format ('%f,%f ', [x,y]);
P.free;
G.free;
End
Procedure Tform1.trackbar1change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar2change (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.