# I dont want this line! How to remove it?

**URL:** <https://discourse.processing.org/t/i-dont-want-this-line-how-to-remove-it/20865>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [May 14, 2020, 1:35pm UTC](https://discourse.processing.org/t/i-dont-want-this-line-how-to-remove-it/20865 "2020-05-14T13:35:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![julia1312](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@julia1312](https://discourse.processing.org/u/julia1312)\
**Post date:** [May 14, 2020, 1:35pm UTC](https://discourse.processing.org/t/i-dont-want-this-line-how-to-remove-it/20865/1 "2020-05-14T13:35:21Z")

</div>

I need to draw an electrical circuit using processing… and I am almost done. I need to draw them using some “vertex” codes. But there is a diagonally line that appeared and I can’t remove it. The lines are changing positions after changing the order of the codes…maybe this could help you to find a solution!

```auto
void setup ()
{
  size (900, 600);
}

void draw ()
{
  background (255);
stroke (0);
strokeWeight (3);
fill (255);
beginShape();
vertex (400, 450); //left short line
vertex (225, 450); //left short line

vertex (225, 150);// upper line
vertex (675, 150);//upper line

vertex (675, 450); //right short line
vertex (500, 450); //right short line

vertex (225, 300); //middle line
vertex (675, 300); //middle line

endShape ();

```

---

<div class="post-metadata">

**Author:** ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)\
**Post date:** [May 14, 2020, 1:47pm UTC](https://discourse.processing.org/t/i-dont-want-this-line-how-to-remove-it/20865/2 "2020-05-14T13:47:05Z")

</div>

The best way to debug something like this is to comment out all the lines and then slowly add them all back in.

So you start out with something like this:

```auto
void draw () {
  background (255);
  stroke (0);
  strokeWeight (3);
  fill (255);
  beginShape();
  
  vertex (400, 450); // left short line
  vertex (225, 450); // left short line

  //vertex (225, 150);// upper line
  //vertex (675, 150);// upper line

  //vertex (675, 450); // right short line
  //vertex (500, 450); // right short line

  //vertex (225, 300); // middle line
  //vertex (675, 300); // middle line

  endShape();
}

```

You run the program and check if the lines are the way you want them to be. If they are, uncomment the next line and check again. Once you get to the line which causes this behaviour, you can begin thinking about what you actually want to do, and how to do it.

This is also the reason you should _never_ write all your code in one go, but in small pieces which you can check at a time.

Now, using the method I described above, I found that the first six vertexes are fine, and the seventh one is causing you problems:

```auto
beginShape();
  
vertex (400, 450); // left short line
vertex (225, 450); // left short line

vertex (225, 150); // upper line
vertex (675, 150); // upper line

vertex (675, 450); // right short line
vertex (500, 450); // right short line

//vertex (225, 300); // <-- this one
//vertex (675, 300); // middle line

endShape();

```

Now it is your job to figure out what you want to do and how to do it. 😉

---

<div class="post-metadata">

**Author:** ![virtuous1](https://avatars.discourse-cdn.com/v4/letter/v/b9bd4f/32.png) [@virtuous1](https://discourse.processing.org/u/virtuous1)\
**Post date:** [May 14, 2020, 3:42pm UTC](https://discourse.processing.org/t/i-dont-want-this-line-how-to-remove-it/20865/3 "2020-05-14T15:42:30Z")

</div>

When using beginShape() and endShape(); you cant create separate lines. For example if I would say

```auto
beginShape();
vertex(0, 0);
vertex(100, 0);

vertex(0, 100);
vertex(100, 100);

```

I would get an hourglass shape _not_ two perpendicular lines.

So either make each line a separate shape or do something like this:

To remove diagonal line:

```auto
  beginShape();
  vertex(400, 450);
  vertex(225, 450);

  vertex(225, 300);
  vertex(675, 300);

  vertex(675, 150);
  vertex(225, 150);

  vertex(225, 300);
  vertex(675, 300);

  vertex(675, 450);
  vertex(500, 450);

  endShape();

```

To turn diagonal line into straight one:

```auto
  beginShape();

  vertex(225, 300); //top of left line
  vertex(225, 150); //top of left line

  vertex(675, 150); //top line

  vertex(675, 300); //top of right line

  vertex(225, 300); //middle line

  vertex(225, 450); //botom left line
  
  vertex(675, 450); //bottom line
  
  vertex(675, 300); //bottom right line

  endShape();

```

I can’t tell you exactly how to do it because I don’t know exactly what you want.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 15, 2020, 6:22am UTC](https://discourse.processing.org/t/i-dont-want-this-line-how-to-remove-it/20865/4 "2020-05-15T06:22:38Z")

</div>

Hello,

Look here:  
[https://processing.org/reference/beginShape\_.html](https://processing.org/reference/beginShape_.html)

I added this to your code:  
`beginShape(LINES);`

And it draws this:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b431e5ae977660026308d473202621a10b94c072.png)

Resources:  
[https://processing.org/](https://processing.org/)  
[https://processing.org/tutorials/pshape/](https://processing.org/tutorials/pshape/)

`:)`
