Polygon.cs 906 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace UnityEditor.Experimental.Rendering.Universal.Path2D
  6. {
  7. internal struct Polygon : IShape
  8. {
  9. public bool isOpenEnded;
  10. public Vector3[] points;
  11. ShapeType IShape.type => ShapeType.Polygon;
  12. bool IShape.isOpenEnded => isOpenEnded;
  13. ControlPoint[] IShape.ToControlPoints()
  14. {
  15. if (points == null)
  16. throw new NullReferenceException("Points array is null");
  17. var controlPoints = new List<ControlPoint>();
  18. foreach (var point in points)
  19. {
  20. controlPoints.Add(new ControlPoint() { position = point });
  21. }
  22. return controlPoints.ToArray();
  23. }
  24. public static Polygon empty = new Polygon() { isOpenEnded = true, points = new Vector3[0] };
  25. }
  26. }