zoukankan      html  css  js  c++  java
  • Firemonkey 绘图 TPathData

    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;
  • 相关阅读:
    day19(上)_IO流2(BufferedReaer,BufferedWriter,BufferedInputStream,BufferedOutputStream)
    day19(下)_IO流4(InputStreamReader,OutputStreamWriter,流操作规律总结)
    Synchronized锁 IT
    Linux查看端口信息命令 IT
    ReentrantLock锁 IT
    让网站实时生成多种电子书:jar、umd、chm、pdf、epub
    mysql性能的检查和调优方法
    新型的大型bbs架构(squid+nginx)
    uchome中的防反复提交机制
    joymobiler V2.7发布,支持pdf文档的生成
  • 原文地址:https://www.cnblogs.com/cb168/p/5422555.html
Copyright © 2011-2022 走看看