Click or drag to resize
DigitalRunePathFigure2F Class
Represents a 2D figure composed of lines and curves.
Inheritance Hierarchy

Namespace: DigitalRune.Graphics
Assembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax
public class PathFigure2F : Figure

The PathFigure2F type exposes the following members.

Constructors
  NameDescription
Public methodPathFigure2F
Initializes a new instance of the PathFigure2F class.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInvalidate
Invalidates cached render data. (Must be called when properties of a figure are changed.)
(Inherited from Figure.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyBoundingShape
Gets the collision shape for bounding volume tests and culling.
(Inherited from Figure.)
Public propertyHitShape
Gets the collision shape for hit tests.
(Inherited from Figure.)
Public propertyIsFilled
Gets or sets a value indicating whether the interior of the figure is filled or empty.
Public propertySegments
Gets the curve segments.
Top
Remarks

The PathFigure2F can be used to define complex shapes composed of lines and curves. The figure is 2D and lies in the xy plane where x-axis points to the right and y-axis points upwards. The curve segments need to be added to the Segments collection. A curve segment is any object that implements ICurve<float, Vector2F>. Examples: LineSegment2F, BezierSegment2F, Path2F, ...

Fill:
Closed shapes within the figure can be filled: A closed shape is defined by consecutive, connected curve segments. For example: Four LineSegment2F can be used to create a filled rectangle. The end of the previous segment needs to match the start of the next segment. The last segment of a closed shape needs to be connected with the first segment.

The property IsFilled determines whether closed shapes will be filled. (The property is by default.)

Stroked vs. Unstroked Segments:
By default all curve segments are stroked meaning that the curve segment will be rendered with a given stroke color and thickness. The StrokedSegment2F can be used to add a curve segment which is not stroked. This class is a decorator that wraps a curve segment and allows to define whether it is stroked or not.

The following example creates rectangles where all or only some edges are stroked:

C#
// Box where all edges are stroked. (Curve segments are stroked by default.)
var boxFigure1 = new PathFigure2F
{
  Segments =
  {
    new LineSegment2F { Point1 = new Vector2F(0, 0), Point2 = new Vector2F(0, 1) },
    new LineSegment2F { Point1 = new Vector2F(0, 1), Point2 = new Vector2F(1, 1) },
    new LineSegment2F { Point1 = new Vector2F(1, 1), Point2 = new Vector2F(1, 0) },
    new LineSegment2F { Point1 = new Vector2F(1, 0), Point2 = new Vector2F(0, 0) }
  }
};
var figureNode1 = new FigureNode(boxFigure1)
{
  StrokeColor = new Vector3F(0, 0, 0),
  StrokeThickness = 2,
  FillColor = new Vector3F(0.5f, 0.5f, 0.5f)
};

// Box where top and bottom edges are stroked.
var boxFigure2 = new PathFigure2F
{
  Segments =
  {
    new StrokedSegment2F(
      new LineSegment2F { Point1 = new Vector2F(0, 0), Point2 = new Vector2F(0, 1) }, 
      false),
    new LineSegment2F { Point1 = new Vector2F(0, 1), Point2 = new Vector2F(1, 1) },
    new StrokedSegment2F(
      new LineSegment2F { Point1 = new Vector2F(1, 1), Point2 = new Vector2F(1, 0) }, 
      false),
    new LineSegment2F { Point1 = new Vector2F(1, 0), Point2 = new Vector2F(0, 0) }
  }
};
var figureNode2 = new FigureNode(boxFigure2)
{
  StrokeColor = new Vector3F(0, 0, 0),
  StrokeThickness = 2,
  FillColor = new Vector3F(0.5f, 0.5f, 0.5f)
};
See Also