unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, TeCanvas;
type
TForm1 = class(TForm)
ButtonColor1: TButtonColor;
ButtonColor2: TButtonColor;
TrackBar1: TTrackBar;
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure ButtonColor1Click(Sender: TObject);
procedure ButtonColor2Click(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
GDIPAPI,GDIPOBJ;
procedure TForm1.ButtonColor1Click(Sender: TObject);
begin
Repaint;
end;
procedure TForm1.ButtonColor2Click(Sender: TObject);
begin
Repaint;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ButtonColor1.Caption:='ɫ1 ';
ButtonColor2.Caption:='ɫ2 ';
ButtonColor1.SymbolColor:=clYellow;
ButtonColor2.SymbolColor:=clRed;
TrackBar1.ShowSelRange:=False;
TrackBar1.Min:=0;
TrackBar1.Max:=360;
end;
procedure TForm1.FormPaint(Sender: TObject);
var
g:TGPGraphics;
rt:TGPRect;
lb:TGPLinearGradientBrush;
c1,c2:TGPColor;
begin
DoubleBuffered:=True;
g:=TGPGraphics.Create(Canvas.Handle);
rt:=MakeRect(60,40,ClientWidth - 120,ClientHeight - 50);
c1:=ColorRefToARGB(ButtonColor1.SymbolColor);
c2:=ColorRefToARGB(ButtonColor2.SymbolColor);
lb:=TGPLinearGradientBrush.Create(rt,c1,c2,TrackBar1.Position);
g.FillEllipse(lb,rt);
lb.Free;
g.Free;
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
Repaint;
end;
end.