/// <summary> /// Adds a RoundedRectangle to the Path. /// </summary> /// <param name="pathBuilder">CanvasPathBuilder</param> /// <param name="x">X offset of the TopLeft corner of the RoundedRectangle</param> /// <param name="y">Y offset of the TopLeft corner of the RoundedRectangle</param> /// <param name="width">Width of the RoundedRectangle</param> /// <param name="height">Height of the RoundedRectangle</param> /// <param name="radiusX">Corner Radius on the x-axis</param> /// <param name="radiusY">Corner Radius on the y-axis</param> public static void AddRoundedRectangleFigure(this CanvasPathBuilder pathBuilder, float x, float y, float width, float height, float radiusX, float radiusY) { // Sanitize the width by taking the absolute value width = Math.Abs(width); // Sanitize the height by taking the absolute value height = Math.Abs(height); var rect = new CanvasRoundRect(x, y, width, height, radiusX, radiusY); pathBuilder.AddRoundedRectangleFigure(rect, true); }
/// <summary> /// Adds the Path Element to the Path. /// </summary> /// <param name="pathBuilder">CanvasPathBuilder object</param> /// <param name="currentPoint">The last active location in the Path before adding /// the PolygonFigure</param> /// <param name="lastElement">The previous PathElement in the Path.</param> /// <returns>The latest location in the Path after adding the PolygonFigure</returns> public override Vector2 CreatePath(CanvasPathBuilder pathBuilder, Vector2 currentPoint, ref ICanvasPathElement lastElement) { // Calculate coordinates var topLeft = new Vector2(_x, _y); if (IsRelative) { topLeft += currentPoint; } // Execute command pathBuilder.AddRoundedRectangleFigure(topLeft.X, topLeft.Y, _width, _height, _radiusX, _radiusY); // No need to update the lastElement or currentPoint here as we are creating // a separate closed figure here.So current point will not change. return(currentPoint); }