Firemonkey  TPathData

TPath控件

procedure TForm12.FormPaint(
  Sender      : TObject;
  Canvas      : TCanvas;
  const ARect : TRectF );
  var
    APath : TPathData;
    MyRect1, MyRect2 : TRectF;
  begin
    MyRect1 := TRectF.Create( 90, 100, 230, 300 );
    MyRect2 := TRectF.Create( 70, 90, 220, 290 );
    APath := TPathData.Create;
    APath.AddEllipse( MyRect1 );
    APath.AddRectangle( MyRect2, 0, 0, AllCorners );

    self.Canvas.DrawPath( APath, 200 );
    Canvas.Fill.Color := TAlphaColorRec.Red;
    Canvas.FillPath( APath, 200 );
    APath.DisposeOf;

  end;

 

  Canvas.Stroke.Color := TAlphaColorRec.Black;
  Canvas.Stroke.Kind := tbrushkind.Solid;

  APath .MoveTo(p1);
  APath .LineTo(p2);
  APath .LineTo(p3);
  APath .LineTo(p4);
  APath .LineTo(p5);
  APath .LineTo(p6);
  APath .LineTo(p7);
  APath .LineTo(p8);
  APath .LineTo(p1);
  self.Canvas.BeginScene;

  self.Canvas.DrawPath(APath , 200);
  Canvas.EndScene;
  APath.DisposeOf;

 

Inkscape 0.91

https://inkscape.org/en/download/windows/

PathData SVG编辑

SVG知识参考

http://www.w3school.com.cn/svg/svg_path.asp

M = moveto(M X,Y) :将画笔移动到指定的坐标位置
L = lineto(L X,Y) :画直线到指定的坐标位置
H = horizontal lineto(H X):画水平线到指定的X坐标位置
V = vertical lineto(V Y):画垂直线到指定的Y坐标位置
C = curveto(C X1,Y1,X2,Y2,ENDX,ENDY):三次贝赛曲线
S = smooth curveto(S X2,Y2,ENDX,ENDY)
Q = quadratic Belzier curve(Q X,Y,ENDX,ENDY):二次贝赛曲线
T = smooth quadratic Belzier curveto(T ENDX,ENDY):映射
A = elliptical Arc(A RX,RY,XROTATION,FLAG1,FLAG2,X,Y):弧线
Z =closepath():关闭路径

画一个三角形

M250 150 L150 350 L350 350 Z

半圆

m 200,250 a 150,30 0 1 0 0,70

 

电池

M0,4 L4,4 L4,0 L8,0 L8,12 L4,12 L4,8 L0,8 L0,4 M8,0 L16,0 L16,12 L8,12 Z

 

添加path路径AddPath

procedure TForm7.FormCreate(Sender: TObject);
var
  apath: TPathData;
  rect: TRect;
  bpath: TPathData;
begin

  apath := TPathData.Create;
  apath.MoveTo(TPointF.Create(10, 10));
  apath.LineTo(TPointF.Create(40, 10));
  apath.LineTo(TPointF.Create(40, 0));
  apath.LineTo(TPointF.Create(100, 0));
  apath.LineTo(TPointF.Create(100, 100));
  apath.LineTo(TPointF.Create(40, 100));
  apath.LineTo(TPointF.Create(40, 40));
  apath.LineTo(TPointF.Create(10, 40));
  apath.LineTo(TPointF.Create(10, 10));

  bpath := TPathData.Create;
  bpath.AddRectangle(TRectF.Create(100, 0, 300, 100), 0, 0, AllCorners);

  Path1.Data.AddPath(apath);
  Path1.Data.AddPath(bpath);

end;

 

posted on 2016-04-22 19:44  lypzxy  阅读(919)  评论(0编辑  收藏  举报