//绘制与填充路径
var
g: TGPGraphics;
path: TGPGraphicsPath;
p: TGPPen;
sb: TGPSolidBrush;
begin
g := TGPGraphics.Create(Canvas.Handle);
p := TGPPen.Create(MakeColor(128,255,0,0),4);
sb := TGPSolidBrush.Create(MakeColor(128,255,255,0));
path := TGPGraphicsPath.Create;
path.StartFigure;
path.AddLine(MakePoint(11,11), MakePoint(222,111));
path.AddBezier(MakePoint(11,11), MakePoint(33,111), MakePoint(66,6),MakePoint(111,111));
path.CloseFigure;
g.DrawPath(p, path);
g.FillPath(sb, path);
p.Free;
sb.Free;
path.Free;
g.Free;
end;
//路径中的拐点结合
var
g: TGPGraphics;
p: TGPPen;
path: TGPGraphicsPath;
p1,p2,p3: TGPPoint;
begin
g := TGPGraphics.Create(Canvas.Handle);
p:= TGPPen.Create(MakeColor(255, 0, 0, 255),8);
path:= TGPGraphicsPath.Create;
p1.X := 50; p1.Y := 200;
p2.X := 100; p2.Y := 200;
p3.X := 100; p3.Y := 250;
path.AddLine(p1, p2);
path.AddLine(p2, p3);
p.SetLineJoin(LineJoinBevel); {设置结合样式}
g.DrawPath(p, path);
path.Free;
p.Free;
g.Free;
end;
路径中的拐点结合样式:
Delphi |
微软 |
说明 |
LineJoinBevel |
Bevel |
指定成斜角的联接。这将产生一个斜角。 |
LineJoinMiter |
Miter |
指定斜联接。这将产生一个锐角或切除角,具体取决于斜联接的长度是否超过斜联接限制。 |
LineJoinMiterClipped |
MiterClipped |
指定斜联接。这将产生一个锐角或斜角,具体取决于斜联接的长度是否超过斜联接限制。 |
LineJoinRound |
Round |
指定圆形联接。这将在两条线之间产生平滑的圆弧。 |