# Is there a way to change the thickness/width of line without using stroke weight?

**URL:** https://discourse.processing.org/t/is-there-a-way-to-change-the-thickness-width-of-line-without-using-stroke-weight/30539
**Category:** Coding Questions
**Created:** [June 6, 2021, 6:22pm UTC](https://discourse.processing.org/t/is-there-a-way-to-change-the-thickness-width-of-line-without-using-stroke-weight/30539 "2021-06-06T18:22:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![uniqueNoSpaces](https://avatars.discourse-cdn.com/v4/letter/u/a587f6/32.png) [@uniqueNoSpaces](https://discourse.processing.org/u/uniqueNoSpaces)
#### Post date: [June 6, 2021, 6:22pm UTC](https://discourse.processing.org/t/is-there-a-way-to-change-the-thickness-width-of-line-without-using-stroke-weight/30539/1 "2021-06-06T18:22:26Z")

</div>

Hello

i’m looking for a way to change the thickness of line(x1,y1,x2,y2) without using stroke weight, because stroke weight affects all shapes on canvas while i just want it to affect the line itself.

is there a way to do that? or at least “restrict” the stroke weight to affect only the drawn line?

please help me

thanks

---

<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: [June 6, 2021, 6:33pm UTC](https://discourse.processing.org/t/is-there-a-way-to-change-the-thickness-width-of-line-without-using-stroke-weight/30539/2 "2021-06-06T18:33:29Z")

</div>

You could use `push()` before and `pop()` after calling `strokeWeight(...)` to restore the original state.

See [the documentation](https://www.processing.org/reference/push_.html).

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [June 6, 2021, 9:25pm UTC](https://discourse.processing.org/t/is-there-a-way-to-change-the-thickness-width-of-line-without-using-stroke-weight/30539/3 "2021-06-06T21:25:25Z")

</div>

strokeWeight(7);  
line… // thick  
strokeWeight(1);  
line… // thin  
line…

---

<div class="post-metadata">

### Author: ![Ov3rM1nD](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ov3rm1nd/32/1756_2.png) [@Ov3rM1nD](https://discourse.processing.org/u/Ov3rM1nD)
#### Post date: [June 7, 2021, 1:15am UTC](https://discourse.processing.org/t/is-there-a-way-to-change-the-thickness-width-of-line-without-using-stroke-weight/30539/4 "2021-06-07T01:15:05Z")

</div>

This is what you want;

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

    circle(width*0.25, height/2, 200);

    line(0, 0, width, height, 10);

    circle(width*0.50, height/2, 200);

    line(width, 0, 0, height, 15);

    circle(width*0.75, height/2, 200);
}

void line(float x1, float y1, float x2, float y2, float weight) {
    pushStyle();
    strokeWeight(weight);
    line(x1, y1, x2, y2);
    popStyle();
}

```

---

<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: [June 7, 2021, 1:27am UTC](https://discourse.processing.org/t/is-there-a-way-to-change-the-thickness-width-of-line-without-using-stroke-weight/30539/5 "2021-06-07T01:27:31Z")

</div>

Hello,

See the p5.js references:

[https://p5js.org/reference/#/p5/push](https://p5js.org/reference/#/p5/push)

`:)`
