/// <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 center = new Vector2(_x, _y);

            if (IsRelative)
            {
                center += currentPoint;
            }

            // Execute command
            pathBuilder.AddPolygonFigure(_numSides, center.X, center.Y, _radius);

            // 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);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds a n-sided polygon figure to the path.
 /// </summary>
 /// <param name="pathBuilder">CanvasPathBuilder</param>
 /// <param name="numSides">Number of sides of the polygon.</param>
 /// <param name="center">Center location of the polygon.</param>
 /// <param name="radius">Radius of the circle cirumscribing the polygon i.e. the distance
 /// of each of the vertices of the polygon from the center.</param>
 public static void AddPolygonFigure(this CanvasPathBuilder pathBuilder, int numSides, Vector2 center,
                                     float radius)
 {
     pathBuilder.AddPolygonFigure(numSides, center.X, center.Y, radius);
 }