随笔 - 2146  文章 - 97 评论 - 11765 trackbacks - 253


测试效果图:



测试代码:

uses GdiPlus;

procedure TForm1.FormPaint(Sender: TObject);
var
  Graphics: IGPGraphics;
  Brush: IGPPathGradientBrush;
  Rect: TGPRect;
  Path: IGPGraphicsPath;
begin
  Graphics := TGPGraphics.Create(Handle);
  Rect.Initialize(10, 10, 180, 100);
  Path := TGPGraphicsPath.Create;
  Path.AddEllipse(Rect);

  Brush := TGPPathGradientBrush.Create(Path);
  Brush.CenterColor := $FF00FF00;
  Brush.SetSurroundColors([$FF000000]);

  Brush.SetFocusScales(0, 0); //这是默认设置
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetFocusScales(0.5, 0);
  Graphics.TranslateTransform(0, Rect.Y + Rect.Height);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetFocusScales(0, 0.5);
  Graphics.TranslateTransform(0, Rect.Y + Rect.Height);
  Graphics.FillEllipse(Brush, Rect);
end;

posted on 2009-12-15 11:58 万一 阅读(...) 评论(...) 编辑 收藏