zoukankan      html  css  js  c++  java
  • GdiPlus[36]: IGPGraphicsPath (三) 路径中的数据


    IGPGraphicsPath.PointCount;   // 点总数
    IGPGraphicsPath.PathPoints;   // 点数组, 浮点型
    IGPGraphicsPath.PathPointsI;  // 点数组, 整型
    IGPGraphicsPath.PathTypes;    // 点类型数组
    IGPGraphicsPath.PathData;     // 点与点类型数据, IGPPathData 类型
    
    IGPGraphicsPath.GetLastPoint; // 尾点
    IGPGraphicsPath.Reverse;      // 反转点顺序
    
    IGPGraphicsPath.GetBounds();  // 获取包围矩形
    { 关于点类型(它是个 Byte 值) } 0 // 指示此点是图形的起始点 1 // 指示此点是线段的两个终结点之一 3 // 指示此点是立方贝塞尔样条的终结点或控制点 $7 // 用于 3 位掩码运算的, 应该不会实际存在 $20 // 指定此点是一个 Marker(标记) $80 // 指定此点是闭合子路径(图形)中的最后一点 //实际读出的值如果不是这样, 应该是该点有双重身份.

    PathPoints、PathTypes、PathData 测试图:



    PathPoints、PathTypes、PathData 测试代码:

    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Graphics: IGPGraphics;
      Path: IGPGraphicsPath;
      Brush,BrushPt,BrushText: IGPSolidBrush;
      Pt: TGPPointF;
      PtType: Byte;
      i: Integer;
    begin
      Graphics := TGPGraphics.Create(Handle);
      Brush := TGPSolidBrush.Create($FFC0C0C0);
      BrushPt := TGPSolidBrush.Create($80FF0000);
      BrushText := TGPSolidBrush.Create($FF000000);
    
      Path := TGPGraphicsPath.Create;
      Path.AddString('A', TGPFontFamily.Create('Arial Black'), [], 200, TGPPoint.Create(0,0), nil);
      Path.AddEllipse(210, 76, 100, 144);
    
      Graphics.FillPath(Brush, Path);
      for i := 0 to Path.PointCount - 1 do
      begin
        Pt := Path.PathPoints[i];
        PtType := Path.PathTypes[i];
        //上两行也可以写作:
        //Pt := Path.PathData.Points[i];
        //PtType := Path.PathData.Types[i];
    
        Graphics.FillRectangle(BrushPt, Pt.X-3, Pt.Y-3, 6, 6);
        Graphics.DrawString(Format('%x', [PtType]), TGPFont.Create(Canvas.Handle), Pt, BrushText);
      end;
    end;
    

    GetLastPoint、Reverse、PathPointsI 测试代码:

    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Path: IGPGraphicsPath;
      PtStart: TGPPoint;
      PtEnd: TGPPointF;
    begin
      Path := TGPGraphicsPath.Create;
      Path.AddRectangle(TGPRect.Create(1, 2, 3, 4));
    
      PtStart := Path.PathPointsI[0];
      PtEnd := Path.GetLastPoint;
      ShowMessageFmt('%d;%d, %g;%g', [PtStart.X, PtStart.Y, PtEnd.X, PtEnd.Y]);
      { (1;2), (1;6) }
    
      Path.Reverse;
      PtStart := Path.PathPointsI[0];
      PtEnd := Path.GetLastPoint;
      ShowMessageFmt('%d;%d, %g;%g', [PtStart.X, PtStart.Y, PtEnd.X, PtEnd.Y]);
      { (1;6), (1;2) }
    end;
    

    GetBounds 测试图:



    GetBounds 测试代码:

    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Graphics: IGPGraphics;
      Path: IGPGraphicsPath;
      Pen: IGPPen;
      Rect: TGPRect;
    begin
      Graphics := TGPGraphics.Create(Handle);
      Pen := TGPPen.Create($FFFF0000, 2);
      Path := TGPGraphicsPath.Create;
      Path.AddLine(20, 20, 150, 100);
    
      Graphics.DrawPath(Pen, Path);
    
      Pen.Width := 1;
      Pen.Color := $FFC0C0C0;
      Path.GetBounds(Rect);
      Graphics.DrawRectangle(Pen, Rect);
    end;
    
  • 相关阅读:
    014Linux几种虚拟网络比较
    013Docker几种存储驱动比较(转发)
    005文件系统压测工具iozone
    016SNAT和DNAT区别
    012docker四种网络模式区别
    001CPU个数/物理核数/逻辑核数/vCPU数之间的区别
    009Ubuntu关闭掉终端或jet公司烦人的bell音
    Java 微信小程序imgSecCheck接口示例-校验一张图片是否含有违法违规内容
    提升NginxTLS/SSL HTTPS 性能的7条优化建议
    MySQL复合索引探究
  • 原文地址:https://www.cnblogs.com/del/p/1626523.html
Copyright © 2011-2022 走看看