PathFigure2F Class |
Namespace: DigitalRune.Graphics
The PathFigure2F type exposes the following members.
Name | Description | |
---|---|---|
PathFigure2F |
Initializes a new instance of the PathFigure2F class.
|
Name | Description | |
---|---|---|
Equals | (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Invalidate |
Invalidates cached render data. (Must be called when properties of a figure are changed.)
(Inherited from Figure.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
BoundingShape |
Gets the collision shape for bounding volume tests and culling.
(Inherited from Figure.) | |
HitShape |
Gets the collision shape for hit tests.
(Inherited from Figure.) | |
IsFilled |
Gets or sets a value indicating whether the interior of the figure is filled or empty.
| |
Segments |
Gets the curve segments.
|
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:
// 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) };