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

//多边形描边与填充
var
  g: TGPGraphics;
  p: TGPPen;
  sb: TGPSolidBrush;
  pts: array[0..4] of TGPPoint;
begin
  g := TGPGraphics.Create(Canvas.Handle);
  sb := TGPSolidBrush.Create(MakeColor(255,255,255));
  p := TGPPen.Create(MakeColor(255,0,0),4);

  pts[0].X := 11;  pts[0].Y := 11;
  pts[1].X := 66;  pts[1].Y := 111;
  pts[2].X := 88;  pts[2].Y := 222;
  pts[3].X := 111; pts[3].Y := 88;
  pts[4].X := 222; pts[4].Y := 66;

  g.DrawPolygon(p, PGPPoint(@pts), Length(pts));  {第二个参数是指针类型, 需亚转换}
  g.FillPolygon(sb, PGPPoint(@pts), Length(pts)); {第三个参数是顶点数}

  p.Free;
  sb.Free;
  g.Free;
end;

posted on 2007-12-27 19:04 万一 阅读(...) 评论(...) 编辑 收藏