/// <summary> /// Adds a quadratic bezier curve to the end of the line. /// </summary> /// <param name="control">The control point of the curve.</param> /// <param name="to">The end point of the curve.</param> /// <returns>This <see cref="IGraphicsPath" />.</returns> public IGraphicsPath AddQuadraticBezier(Vector2 control, Vector2 to) { _sink?.AddQuadraticBezier( new QuadraticBezierSegment { Point1 = control.ToRawVector2(), Point2 = to.ToRawVector2() }); return(this); }
/// <summary> /// Fills the inside of an ellipse. /// </summary> /// <param name="point">The center point of the ellipse.</param> /// <param name="radius">The radius of the elipse in each axis.</param> public void FillEllipse(Vector2 point, Vector2 radius) { _renderTarget.FillEllipse( new Ellipse { Point = point.ToRawVector2(), RadiusX = radius.X, RadiusY = radius.Y }, FillBrush); }
/// <summary> /// Fills the inside of a circle. /// </summary> /// <param name="point">The center point of the circle.</param> /// <param name="radius">The radius of the circle.</param> public void FillCircle(Vector2 point, float radius) { _renderTarget.FillEllipse( new Ellipse { Point = point.ToRawVector2(), RadiusX = radius, RadiusY = radius }, FillBrush); }
/// <summary> /// Adds a cubic bezier curve to the end of the line. /// </summary> /// <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 IGraphicsPath AddCubicBezier(Vector2 controlA, Vector2 controlB, Vector2 to) { _sink?.AddBezier( new BezierSegment { Point1 = controlA.ToRawVector2(), Point2 = controlB.ToRawVector2(), Point3 = to.ToRawVector2() }); return(this); }
/// <summary> /// Draws an ellipse. /// </summary> /// <param name="point">The center point of the ellipse.</param> /// <param name="radius">The radius of the elipse in each axis.</param> public void DrawEllipse(Vector2 point, Vector2 radius) { _renderTarget.DrawEllipse( new Ellipse { Point = point.ToRawVector2(), RadiusX = radius.X, RadiusY = radius.Y }, LineBrush, _lineWidth, _strokeStyle); }
/// <summary> /// Adds an arc of an elipse to the end of the path. /// </summary> /// <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> /// <returns> /// This <see cref="IGraphicsPath" />. /// </returns> public IGraphicsPath AddArc(Vector2 to, Vector2 radius, float angle, bool clockwise, bool isLarge) { _sink?.AddArc( new ArcSegment { Point = to.ToRawVector2(), RotationAngle = (float)(angle * 180 / Math.PI), Size = radius.ToSize2F(), SweepDirection = clockwise ? SweepDirection.Clockwise : SweepDirection.CounterClockwise, ArcSize = isLarge ? ArcSize.Large : ArcSize.Small }); return(this); }
/// <summary> /// Adds a line to the end of the path. /// </summary> /// <param name="to">The end point of the line.</param> /// <returns>This <see cref="IGraphicsPath" />.</returns> public IGraphicsPath AddLine(Vector2 to) { _sink?.AddLine(to.ToRawVector2()); return(this); }
/// <summary> /// Starts the path at the point given. /// </summary> /// <param name="point">The point to start the path at.</param> /// <returns>This <see cref="IGraphicsPath" />.</returns> public IGraphicsPath Start(Vector2 point) { _sink?.BeginFigure(point.ToRawVector2(), FigureBegin.Filled); return(this); }
/// <summary> /// Adds a cubic bezier curve to the end of the line. /// </summary> /// <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 IGraphicsPath AddCubicBezier(Vector2 controlA, Vector2 controlB, Vector2 to) { _sink?.AddBezier( new BezierSegment { Point1 = controlA.ToRawVector2(), Point2 = controlB.ToRawVector2(), Point3 = to.ToRawVector2() }); return this; }
/// <summary> /// Adds a quadratic bezier curve to the end of the line. /// </summary> /// <param name="control">The control point of the curve.</param> /// <param name="to">The end point of the curve.</param> /// <returns>This <see cref="IGraphicsPath" />.</returns> public IGraphicsPath AddQuadraticBezier(Vector2 control, Vector2 to) { _sink?.AddQuadraticBezier( new QuadraticBezierSegment { Point1 = control.ToRawVector2(), Point2 = to.ToRawVector2() }); return this; }
/// <summary> /// Adds an arc of an elipse to the end of the path. /// </summary> /// <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> /// <returns> /// This <see cref="IGraphicsPath" />. /// </returns> public IGraphicsPath AddArc(Vector2 to, Vector2 radius, float angle, bool clockwise, bool isLarge) { _sink?.AddArc( new ArcSegment { Point = to.ToRawVector2(), RotationAngle = (float) (angle * 180 / Math.PI), Size = radius.ToSize2F(), SweepDirection = clockwise ? SweepDirection.Clockwise : SweepDirection.CounterClockwise, ArcSize = isLarge ? ArcSize.Large : ArcSize.Small }); return this; }
/// <summary> /// Adds a line to the end of the path. /// </summary> /// <param name="to">The end point of the line.</param> /// <returns>This <see cref="IGraphicsPath" />.</returns> public IGraphicsPath AddLine(Vector2 to) { _sink?.AddLine(to.ToRawVector2()); return this; }
/// <summary> /// Starts the path at the point given. /// </summary> /// <param name="point">The point to start the path at.</param> /// <returns>This <see cref="IGraphicsPath" />.</returns> public IGraphicsPath Start(Vector2 point) { _sink?.BeginFigure(point.ToRawVector2(), FigureBegin.Filled); return this; }
/// <summary> /// Determines whether the path contains the specified point. /// </summary> /// <param name="point">The point.</param> /// <param name="transform"></param> /// <returns><see langword="true" /> if the point is within this path; otherwise <see langword="false" />.</returns> public bool ContainsPoint(Vector2 point, Matrix3x2 transform) => PathGeometry.FillContainsPoint( point.ToRawVector2(), transform.ToRawMatrix3x2(), PathGeometry.FlatteningTolerance);
/// <summary> /// Draws a line between two points. /// </summary> /// <param name="from">The point to draw the line from.</param> /// <param name="to">The point to draw the line to.</param> public void DrawLine(Vector2 @from, Vector2 to) { _renderTarget.DrawLine(@from.ToRawVector2(), to.ToRawVector2(), LineBrush, _lineWidth, _strokeStyle); }