当前位置:   article > 正文

GDI+ 路径 - IsVisible、IsOutlineVisible

isoutlinevisible

GDI+ 路径 - IsVisible、IsOutlineVisible

再学 GDI+[51]: 路径 - IsVisible,IsOutlineVisible

  代码文件:unit Unit1;

  1. interface
  2. uses
  3.  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  4.  Dialogs;
  5. type
  6.  TForm1 = class(TForm)
  7.   procedure FormCreate(Sender: TObject);
  8.   procedure FormDestroy(Sender: TObject);
  9.   procedure FormPaint(Sender: TObject);
  10.   procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
  11.  end;
  12. var
  13.  Form1: TForm1;
  14. implementation
  15. {$R *.dfm}
  16. uses GDIPOBJ, GDIPAPI;
  17. var
  18.  path1,path2,path3: TGPGraphicsPath;
  19.  p: TGPPen;
  20. procedure TForm1.FormCreate(Sender: TObject);
  21. var
  22.  r: TRect;
  23. begin
  24.  path1 := TGPGraphicsPath.Create;
  25.  path2 := TGPGraphicsPath.Create;
  26.  path3 := TGPGraphicsPath.Create;
  27.  p := TGPPen.Create(aclRed, 3);
  28.  path1.AddLine(0, 0, ClientWidth, ClientHeight);
  29.  r := ClientRect;
  30.  InflateRect(r, -ClientWidth div 3, -ClientHeight div 3);
  31.  OffsetRect(r, -Trunc((r.Right-r.Left) * 0.6), -Trunc((r.Bottom-r.Top) * 0.6));
  32.  path2.AddRectangle(MakeRect(r));
  33.  OffsetRect(r, r.Right-r.Left, r.Bottom-r.Top);
  34.  path3.AddEllipse(MakeRect(r));
  35. end;
  36. procedure TForm1.FormDestroy(Sender: TObject);
  37. begin
  38.  path1.Free;
  39.  path2.Free;
  40.  path3.Free;
  41.  p.Free;
  42. end;
  43. procedure TForm1.FormPaint(Sender: TObject);
  44. var
  45.  g: TGPGraphics;
  46. begin
  47.  g := TGPGraphics.Create(Canvas.Handle);
  48.  g.DrawPath(p, path1);
  49.  g.DrawPath(p, path2);
  50.  g.DrawPath(p, path3);
  51.  g.Free;
  52. end;
  53. procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  54.  Y: Integer);
  55. begin
  56.  Text := '';
  57. // if path1.IsVisible(MakePoint(X,Y)) then Text := '在 path1 内';
  58.  if path2.IsVisible(MakePoint(X,Y)) then Text := '在矩形内';
  59.  if path3.IsVisible(MakePoint(X,Y)) then Text := '在椭圆内';
  60.  if path1.IsOutlineVisible(X, Y, p) then Text := '在直线上';
  61.  if path2.IsOutlineVisible(X, Y, p) then Text := '在矩形的边线上';
  62.  if path3.IsOutlineVisible(X, Y, p) then Text := '在椭圆的圆周线上';
  63. end;
  64. end.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/448372
推荐阅读
相关标签
  

闽ICP备14008679号