text: // Daniel Shiffman
  // http://codingtra.in
  // Islamic Star Patterns
  // Video Part 1: https://youtu.be/sJ6pMLp_IaI
  // Video Part 2: [coming soon]
  // Based on: http://www.cgl.uwaterloo.ca/csk/projects/starpatterns/
  
  // Repo with more tiling patterns and features
  // https://github.com/CodingTrain/StarPatterns
  
  function Polygon() {
    this.vertices = [];
    this.edges = [];
  
    this.addVertex = function(x, y) {
      var a = createVector(x, y);
      var total = this.vertices.length;
      if (total > 0) {
        var prev = this.vertices[total - 1];
        var edge = new Edge(prev, a);
        this.edges.push(edge);
      }
      this.vertices.push(a);
    }
  
    this.close = function() {
      var total = this.vertices.length;
      var last = this.vertices[total - 1];
      var first = this.vertices[0];
      var edge = new Edge(last, first);
      this.edges.push(edge);
    }
  
    this.hankin = function() {
      for (var i = 0; i < this.edges.length; i++) {
        this.edges[i].hankin();
      }
  
      for (var i = 0; i < this.edges.length; i++) {
        for (var j = 0; j < this.edges.length; j++) {
          if (i !== j) {
            this.edges[i].findEnds(this.edges[j]);
          }
        }
      }
    }
  
    this.show = function() {
      for (var i = 0; i < this.edges.length; i++) {
        this.edges[i].show();
      }
    }
  
  }
  