Ejemplo n.º 1
0
 /// <summary>
 /// Creates a Polygon in the shape of a rectangle.
 /// </summary>
 /// <param name="width">The width of the rectangle.</param>
 /// <param name="height">The height of the rectangle.</param>
 /// <returns>A rectangle shaped Polygon.</returns>
 public static Polygon CreateRectangle(float width, float height) {
     var poly = new Polygon();
     poly.Add(0, 0);
     poly.Add(width, 0);
     poly.Add(width, height);
     poly.Add(0, height);
     return poly;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a Polygon in the shape of a circle.
 /// </summary>
 /// <param name="radius">The radius of the circle.</param>
 /// <param name="steps">How many steps to use to create the circle (higher is rounder.)</param>
 /// <returns>A circle shaped Polygon.</returns>
 public static Polygon CreateCircle(float radius, int steps = 32) {
     var poly = new Polygon();
     (steps).Times((i) => {
         var angle = 360f / steps * i;
         poly.Add(Util.PolarX(angle, radius) + radius, Util.PolarY(angle, radius) + radius);
     });
     return poly;
 }