Figure

Figure class

图。形状的容器.

public class Figure : ObjectWithBounds

构造函数

姓名描述
Figure()默认构造函数。

特性

姓名描述
override Bounds { get; }获取或设置对象的边界。
IsClosed { get; set; }获取或设置该图窗是否闭合的值。只有在 第一个和最后一个图形的形状是连续形状的情况下,封闭图形才会有所不同。在这种情况下,第一个形状的第一个点将 由最后一个形状的最后一个点的直线连接。
Segments { get; }获取整个图形段。
Shapes { get; }获取图形形状。

方法

姓名描述
AddShape(Shape)为图形添加形状。
AddShapes(Shape[])为图形添加一系列形状。
override GetBounds(Matrix)获取对象的边界。
override GetBounds(Matrix, Pen)获取对象的边界。
RemoveShape(Shape)从图中删除一个形状。
RemoveShapes(Shape[])从图中删除一系列形状。
Reverse()反转此图形形状顺序和形状点顺序。
override Transform(Matrix)将指定的变换应用于形状。

例子

此示例使用 GraphicsPath 和 Graphics 类在图像表面上创建和操作图形。示例在 GraphicsPath 类的帮助下创建一个新图像(Tiff 类型),清除表面并绘制路径。最后调用 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.Clear(Color.Wheat);

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

        //创建一个Figure类的实例
        Aspose.Imaging.Figure figure = new Aspose.Imaging.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);

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

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

也可以看看