/// <summary> /// Draws a cubic bezier curve to the end of the line. /// </summary> /// <param name="from">The start point of the curve.</param> /// <param name="controlA">The first control point of the curve.</param> /// <param name="controlB">The second control point of the curve.</param> /// <param name="to">The end point of the curve.</param> /// <returns>This <see cref="IGraphicsPath" />.</returns> public void DrawCubicBezier(Vector2 @from, Vector2 controlA, Vector2 controlB, Vector2 to) { using (GraphicsPath path = new GraphicsPath(DirectXResourceManager.CreatePathGeometry())) { path.Start(from) .AddCubicBezier(controlA, controlB, to) .End(false); _renderTarget.DrawGeometry(path.PathGeometry, LineBrush, _lineWidth, _strokeStyle); } }
/// <summary> /// Draws a set of lines joining the array of points given. /// </summary> /// <param name="points">The points to draw lines between.</param> public void DrawLines(Vector2[] points) { using (GraphicsPath path = new GraphicsPath(DirectXResourceManager.CreatePathGeometry())) { path.Start(points[0]) .AddLines(new ArraySegment <Vector2>(points, 1, points.Length - 1)) .End(false); _renderTarget.DrawGeometry(path.PathGeometry, LineBrush, _lineWidth, _strokeStyle); } }
/// <summary> /// Draws an arc of an elipse. /// </summary> /// <param name="from">The start point of the arc.</param> /// <param name="to">The end point of the arc.</param> /// <param name="radius">The radius of the arc.</param> /// <param name="angle">The angle of the arc, in radians.</param> /// <param name="clockwise">If set to <see langword="true" /> the arc will be drawn clockwise.</param> /// <param name="isLarge">Specifies whether the given arc is larger than 180 degrees</param> public void DrawArc(Vector2 @from, Vector2 to, Vector2 radius, float angle, bool clockwise, bool isLarge) { using (GraphicsPath path = new GraphicsPath(DirectXResourceManager.CreatePathGeometry())) { path.Start(from) .AddArc(to, radius, angle, clockwise, isLarge) .End(false); _renderTarget.DrawGeometry(path.PathGeometry, LineBrush, _lineWidth, _strokeStyle); } }
/// <summary> /// Creates an <see cref="IGraphicsPath" /> that can be used to draw a path with this graphics object. /// </summary> /// <returns></returns> public IGraphicsPath CreatePath() => new GraphicsPath(DirectXResourceManager.CreatePathGeometry());