GraphicsPath::IsVisible (constPointF&,constGraphics*) 方法 (gdipluspath.h)

GraphicsPath::IsVisible 方法确定指定点是否位于由指定的 Graphics 对象填充此路径时所填充的区域。

语法

BOOL IsVisible(
  const PointF & point,
  const Graphics *g
);

参数

point

对要测试的点的引用。

g

可选。 指向 Graphics 对象的指针,该对象指定世界到设备转换。 如果此参数的值为 NULL,则测试以世界坐标完成;否则,测试以设备坐标完成。 默认值为 NULL。

返回值

如果测试点位于此路径的内部,则此方法返回 TRUE;否则,它将返回 FALSE

注解

示例

以下示例创建一个椭圆形路径,并使用较窄的黑色笔绘制该路径。 然后,代码测试数组中的每个点,以查看该点是否位于路径的内部。 位于内部的点被涂成绿色,不在内部的点被涂成红色。

VOID IsVisibleExample(HDC hdc)
{
   Graphics graphics(hdc);

   INT j;
   Pen blackPen(Color(255, 0, 0, 0), 1);
   SolidBrush brush(Color(255, 255, 0,  0));

   // Create and draw a path.
   GraphicsPath path;
   path.AddEllipse(50, 50, 200, 100);
   graphics.DrawPath(&blackPen, &path);

   // Create an array of four points, and determine whether each
   // point in the array touches the outline of the path.
   // If a point touches the outline, paint it green.
   // If a point does not touch the outline, paint it red.
   PointF[] = {
      PointF(50, 100),
      PointF(250, 100),
      PointF(150, 170),
      PointF(180, 60)};

   for(j = 0; j <= 3; ++j)
   {
      if(path.IsVisible(points[j], &graphics))
         brush.SetColor(Color(255, 0, 255,  0));
      else
         brush.SetColor(Color(255, 255, 0,  0));

      graphics.FillEllipse(&brush, points[j].X - 3.0f, points[j].Y - 3.0f, 6.0f, 6.0f);
   }
}

要求

   
标头 gdipluspath.h

另请参阅

使用区域进行剪裁

构造并绘制轨迹

创建路径渐变

显卡

GraphicsPath

IsOutlineVisible 方法

IsVisible 方法

路径

PointF