类 GraphicsPath

GraphicsPath class

表示一系列相连的直线和曲线。此类不可被继承。

public sealed class GraphicsPath : ObjectWithBounds

构造函数

名称描述
GraphicsPath()初始化 GraphicsPath 类的新实例。
GraphicsPath(Figure[])初始化 GraphicsPath 类的新实例。
GraphicsPath(FillMode)初始化 GraphicsPath 类的新实例。
GraphicsPath(Figure[], FillMode)初始化 GraphicsPath 类的新实例。

属性

名称描述
override Bounds { get; }获取或设置对象的边界。
Figures { get; }获取路径图形。
FillMode { get; set; }获取或设置一个 FillMode 枚举,用于确定此 GraphicsPath 中形状内部的填充方式。

方法

名称描述
AddFigure(Figure)添加一个新图形。
AddFigures(Figure[])添加新图形。
AddPath(GraphicsPath)将指定的 GraphicsPath 附加到此路径。
AddPath(GraphicsPath, bool)将指定的 GraphicsPath 附加到此路径。
DeepClone()执行此图形路径的深度克隆。
override Equals(object)检查对象是否相等。
Flatten()将此路径中的每条曲线转换为一系列相连的线段。
Flatten(Matrix)应用指定的变换,然后将此 GraphicsPath 中的每条曲线转换为一系列相连的线段。
Flatten(Matrix, float)将此 GraphicsPath 中的每条曲线转换为一系列相连的线段。
override GetBounds(Matrix)获取对象的边界。
override GetBounds(Matrix, Pen)获取对象的边界。
override GetHashCode()获取当前对象的哈希码。
IsOutlineVisible(Point, Pen)指示在使用指定的 Pen 绘制时,指定的点是否位于此 GraphicsPath 的轮廓内(下方)。
IsOutlineVisible(PointF, Pen)指示在使用指定的 Pen 绘制时,指定的点是否位于此 GraphicsPath 的轮廓内(下方)。
IsOutlineVisible(float, float, Pen)指示在使用指定的 Pen 绘制时,指定的点是否位于此 GraphicsPath 的轮廓内(下方)。
IsOutlineVisible(int, int, Pen)指示在使用指定的 Pen 绘制时,指定的点是否位于此 GraphicsPath 的轮廓内(下方)。
IsOutlineVisible(Point, Pen, Graphics)指示在使用指定的 Pen 并使用指定的 Graphics 绘制时,指定的点是否位于此 GraphicsPath 的轮廓内(下方)。
IsOutlineVisible(PointF, Pen, Graphics)指示在使用指定的 Pen 并使用指定的 Graphics 绘制时,指定的点是否位于此 GraphicsPath 的轮廓内(下方)。
IsOutlineVisible(float, float, Pen, Graphics)指示在使用指定的 Pen 并使用指定的 Graphics 绘制时,指定的点是否位于此 GraphicsPath 的轮廓内(下方)。
IsOutlineVisible(int, int, Pen, Graphics)指示在使用指定的 Pen 并使用指定的 Graphics 绘制时,指定的点是否位于此 GraphicsPath 的轮廓内(下方)。
IsVisible(Point)指示指定的点是否位于此 GraphicsPath 内部。
IsVisible(PointF)指示指定的点是否位于此 GraphicsPath 内部。
IsVisible(float, float)指示指定的点是否位于此 GraphicsPath 内部。
IsVisible(int, int)指示指定的点是否位于此 GraphicsPath 内部。
IsVisible(Point, Graphics)指示指定的点是否位于此 GraphicsPath 内部。
IsVisible(PointF, Graphics)指示指定的点是否位于此 GraphicsPath 内部。
IsVisible(float, float, Graphics)指示指定的点是否位于此 GraphicsPath 在指定的 Graphics 可见裁剪区域内。
IsVisible(int, int, Graphics)指示在使用指定的 Graphics 时,指定的点是否位于此 GraphicsPath 内部。
RemoveFigure(Figure)删除一个图形。
RemoveFigures(Figure[])删除图形。
Reset()清空图形路径并将 FillMode 设置为 Alternate。
Reverse()反转此 GraphicsPath 中每个形状的图形、形状和点的顺序。
override Transform(Matrix)对形状应用指定的变换。
Warp(PointF[], RectangleF)对该 GraphicsPath 应用由矩形和平行四边形定义的扭曲变换。
Warp(PointF[], RectangleF, Matrix)对该 GraphicsPath 应用由矩形和平行四边形定义的扭曲变换。
Warp(PointF[], RectangleF, Matrix, WarpMode)对该 GraphicsPath 应用由矩形和平行四边形定义的扭曲变换。
Warp(PointF[], RectangleF, Matrix, WarpMode, float)对该 GraphicsPath 应用由矩形和平行四边形定义的扭曲变换。
Widen(Pen)向路径添加额外的轮廓。
Widen(Pen, Matrix)GraphicsPath 添加额外的轮廓。
Widen(Pen, Matrix, float)将此 GraphicsPath 替换为在使用指定笔绘制此路径时填充的区域所包围的曲线。

示例

此示例使用 GraphicsPath 和 Graphics 类在图像表面上创建和操作图形。示例创建一个新的 Image(Tiff 类型),清除表面并借助 GraphicsPath 类绘制路径。最后调用 Graphics 类公开的 DrawPath 方法在表面上渲染这些路径。

[C#]

//创建 FileStream 的实例
using (System.IO.FileStream stream = new System.IO.FileStream(@"C:\temp\output.tiff", System.IO.FileMode.Create))
{
    //创建 TiffOptions 的实例并设置其各种属性
    Aspose.Imaging.ImageOptions.TiffOptions tiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);

    //为 ImageOptions 实例设置源
    tiffOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

    //创建 Image 的实例
    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(tiffOptions, 500, 500))
    {
        //创建并初始化 Graphics 类的实例
        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

        //清除 Graphics 表面
        graphics.Clear(Color.Wheat);

        //创建 GraphicsPath 类的实例
        Aspose.Imaging.GraphicsPath graphicspath = new Aspose.Imaging.GraphicsPath();

        //创建 Figure 类的实例
        Aspose.Imaging.Figure figure = new Aspose.Imaging.Figure();

        //向 Figure 对象添加形状
        figure.AddShape(new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(10f, 10f, 300f, 300f)));
        figure.AddShape(new Aspose.Imaging.Shapes.EllipseShape(new Aspose.Imaging.RectangleF(50f, 50f, 300f, 300f)));
        figure.AddShape(new Aspose.Imaging.Shapes.PieShape(new Aspose.Imaging.RectangleF(new Aspose.Imaging.PointF(250f, 250f), new Aspose.Imaging.SizeF(200f, 200f)), 0f, 45f));

        //将 Figure 对象添加到 GraphicsPath
        graphicspath.AddFigure(figure);

        //使用颜色为 Black 的 Pen 对象绘制路径
        graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 2), graphicspath);

        // 保存所有更改。
        image.Save();
    }
}

另请参见