GraphicsPath

GraphicsPath class

Represents a series of connected lines and curves. This class cannot be inherited.

public sealed class GraphicsPath : ObjectWithBounds

Constructors

NameDescription
GraphicsPath()Initializes a new instance of the GraphicsPath class.
GraphicsPath(Figure[])Initializes a new instance of the GraphicsPath class.
GraphicsPath(FillMode)Initializes a new instance of the GraphicsPath class.
GraphicsPath(Figure[], FillMode)Initializes a new instance of the GraphicsPath class.

Properties

NameDescription
override Bounds { get; }Gets or sets the object’s bounds.
Figures { get; }Gets the path figures.
FillMode { get; set; }Gets or sets a FillMode enumeration that determines how the interiors of shapes in this GraphicsPath are filled.

Methods

NameDescription
AddFigure(Figure)Adds a new figure.
AddFigures(Figure[])Adds new figures.
AddPath(GraphicsPath)Appends the specified GraphicsPath to this path.
AddPath(GraphicsPath, bool)Appends the specified GraphicsPath to this path.
DeepClone()Performs a deep clone of this graphics path.
override Equals(object)Check if objects are equal.
Flatten()Converts each curve in this path into a sequence of connected line segments.
Flatten(Matrix)Applies the specified transform and then converts each curve in this GraphicsPath into a sequence of connected line segments.
Flatten(Matrix, float)Converts each curve in this GraphicsPath into a sequence of connected line segments.
override GetBounds(Matrix)Gets the object’s bounds.
override GetBounds(Matrix, Pen)Gets the object’s bounds.
override GetHashCode()Get hash code of the current object.
IsOutlineVisible(Point, Pen)Indicates whether the specified point is contained within (under) the outline of this GraphicsPath when drawn with the specified Pen.
IsOutlineVisible(PointF, Pen)Indicates whether the specified point is contained within (under) the outline of this GraphicsPath when drawn with the specified Pen.
IsOutlineVisible(float, float, Pen)Indicates whether the specified point is contained within (under) the outline of this GraphicsPath when drawn with the specified Pen.
IsOutlineVisible(int, int, Pen)Indicates whether the specified point is contained within (under) the outline of this GraphicsPath when drawn with the specified Pen.
IsOutlineVisible(Point, Pen, Graphics)Indicates whether the specified point is contained within (under) the outline of this GraphicsPath when drawn with the specified Pen and using the specified Graphics.
IsOutlineVisible(PointF, Pen, Graphics)Indicates whether the specified point is contained within (under) the outline of this GraphicsPath when drawn with the specified Pen and using the specified Graphics.
IsOutlineVisible(float, float, Pen, Graphics)Indicates whether the specified point is contained within (under) the outline of this GraphicsPath when drawn with the specified Pen and using the specified Graphics.
IsOutlineVisible(int, int, Pen, Graphics)Indicates whether the specified point is contained within (under) the outline of this GraphicsPath when drawn with the specified Pen and using the specified Graphics.
IsVisible(Point)Indicates whether the specified point is contained within this GraphicsPath.
IsVisible(PointF)Indicates whether the specified point is contained within this GraphicsPath.
IsVisible(float, float)Indicates whether the specified point is contained within this GraphicsPath.
IsVisible(int, int)Indicates whether the specified point is contained within this GraphicsPath.
IsVisible(Point, Graphics)Indicates whether the specified point is contained within this GraphicsPath.
IsVisible(PointF, Graphics)Indicates whether the specified point is contained within this GraphicsPath.
IsVisible(float, float, Graphics)Indicates whether the specified point is contained within this GraphicsPath in the visible clip region of the specified Graphics.
IsVisible(int, int, Graphics)Indicates whether the specified point is contained within this GraphicsPath, using the specified Graphics.
RemoveFigure(Figure)Removes a figure.
RemoveFigures(Figure[])Removes figures.
Reset()Empties the graphics path and sets the FillMode to Alternate.
Reverse()Reverses the order of figures, shapes, and points in each shape of this GraphicsPath.
override Transform(Matrix)Applies the specified transformation to the shape.
Warp(PointF[], RectangleF)Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.
Warp(PointF[], RectangleF, Matrix)Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.
Warp(PointF[], RectangleF, Matrix, WarpMode)Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.
Warp(PointF[], RectangleF, Matrix, WarpMode, float)Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.
Widen(Pen)Adds an additional outline to the path.
Widen(Pen, Matrix)Adds an additional outline to the GraphicsPath.
Widen(Pen, Matrix, float)Replaces this GraphicsPath with curves that enclose the area that is filled when this path is drawn by the specified pen.

Examples

This examples make use of GraphicsPath and Graphics class to create and manipulate Figures on an Image surface. Example creates a new Image (of type Tiff), clears the surface and draws paths with the help of GraphicsPath class. At the end DrawPath method exposed by Graphics class is called to render the paths on surface.

[C#]

//Create an instance of FileStream
using (System.IO.FileStream stream = new System.IO.FileStream(@"C:\temp\output.tiff", System.IO.FileMode.Create))
{
    //Create an instance of TiffOptions and set its various properties
    Aspose.Imaging.ImageOptions.TiffOptions tiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);

    //Set the source for the instance of ImageOptions
    tiffOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

    //Create an instance of Image 
    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(tiffOptions, 500, 500))
    {
        //Create and initialize an instance of Graphics class
        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(image);

        //Clear Graphics surface
        graphics.Clear(Color.Wheat);

        //Create an instance of GraphicsPath class
        Aspose.Imaging.GraphicsPath graphicspath = new Aspose.Imaging.GraphicsPath();

        //Create an instance of Figure class
        Aspose.Imaging.Figure figure = new Aspose.Imaging.Figure();

        //Add Shapes to Figure object
        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));

        //Add Figure object to GraphicsPath
        graphicspath.AddFigure(figure);

        //Draw path with Pen object of color Black
        graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 2), graphicspath);

        // save all changes.
        image.Save();
    }
}

See Also