# PShape vertice are not actually joined

**URL:** <https://discourse.processing.org/t/pshape-vertice-are-not-actually-joined/31201>\
**Category:** Processing\
**Created:** [July 12, 2021, 8:33am UTC](https://discourse.processing.org/t/pshape-vertice-are-not-actually-joined/31201 "2021-07-12T08:33:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eamoex](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@Eamoex](https://discourse.processing.org/u/Eamoex)\
**Post date:** [July 12, 2021, 8:33am UTC](https://discourse.processing.org/t/pshape-vertice-are-not-actually-joined/31201/1 "2021-07-12T08:33:14Z")

</div>

Hi, I’m using `PShape` to draw an open path called `pth`. I add a certain number of `vertex(int x, int y)`, then `shape(pth)` into a PDF to edit in Illustrator for path simplification and appearance rework. My problem: the resulting path is a collection of disconnected segments, i.e. the vertice aren’t actually joined.

There are Illustrator plugins which do that, but the actual project handles hundreds of these open paths and it takes litterally hours to join all the loose segments.

Is there a setting in the class that makes the vertice of a `PShape` _actually joined_?

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [July 18, 2021, 7:31pm UTC](https://discourse.processing.org/t/pshape-vertice-are-not-actually-joined/31201/2 "2021-07-18T19:31:03Z")

</div>

do you `endShape(CLOSE)`? otherwise a snippet of the code would help 🙂

---

<div class="post-metadata">

**Author:** ![Eamoex](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@Eamoex](https://discourse.processing.org/u/Eamoex)\
**Post date:** [July 19, 2021, 8:52am UTC](https://discourse.processing.org/t/pshape-vertice-are-not-actually-joined/31201/3 "2021-07-19T08:52:16Z")

</div>

Thanks for replying. I’m sorry but I got mixed up. There are projects where I use `line()`, others where I use `PShape` objects with method `vertex()`. This one uses calls to `line()` which were buried into some method. Bottom line is:

- `line()` does not actually connect vertice, whereas `vertex()` does.

It seems shamefully obvious now that I’ve been thinking somewhat deeply about it, but I got confused by what the screen shows (connected segments) and what the vectors in the exported file actually are. For any beginner facing this kind of problem, I’ve made an example program to show how a collection of `line()` segments VS connected `vertex()` behave. Note that the resulting black squiggle is made using `vertex()` and the red one using `line()`. Their properties are otherwise identical on screen; to really understand the difference, you need a vector editing program to open the exported PDF, ungroup the objects and observe the (un)joining of segments.

```auto
// library needed to export PDFs
import processing.pdf.*;

// two-dimensional array to store vertice x/y pairs
int[][] the_vertice;

// PShape object
PShape the_shape;

void setup() {
  size(100, 100, P2D);

  // initialize vertice array
  the_vertice = new int[5][2];

  // radomize x/y pairs
  randomizeVrtx();

  // define PShape object
  the_shape = createShape();
  the_shape.beginShape();
  the_shape.stroke(0);
  the_shape.strokeWeight(1);
  the_shape.noFill();
  for (int i=0; i<the_vertice.length; i++) {
    for (int j=0; j<the_vertice[i].length; j++) {
      the_shape.vertex(the_vertice[i][0], the_vertice[i][1]);
    }
  }
  the_shape.endShape();

  // start logging graphics into PDF
  beginRecord(PDF, "vectorz.pdf");

  // draw shape using PShape object
  shape(the_shape);

  // randomize x/y pairs again
  randomizeVrtx();

  // set Processing's main canvas drawing properties
  stroke(255, 0, 0, 255);
  strokeWeight(1);
  noFill();

  // draw shape using Processing's line method
  for (int i=0; i<the_vertice.length-1; i++) {
    for (int j=0; j<the_vertice[i].length; j++) {
      line(the_vertice[i][0], the_vertice[i][1], the_vertice[i+1][0], the_vertice[i+1][1]);
    }
  }

  // stop logging to PDF and save file
  endRecord();
}

// method to randomize x/y pairs
void randomizeVrtx() {
  for (int i=0; i<the_vertice.length; i++) {
    for (int j=0; j<the_vertice[i].length; j++) {
      the_vertice[i][j] = int(random(70)+15.0);
    }
  }
}

```
