# How to get current stroke weight?

**URL:** <https://discourse.processing.org/t/how-to-get-current-stroke-weight/23695>\
**Category:** Beginners\
**Created:** [September 5, 2020, 4:40pm UTC](https://discourse.processing.org/t/how-to-get-current-stroke-weight/23695 "2020-09-05T16:40:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_riptano](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mr\_riptano](https://discourse.processing.org/u/mr_riptano)\
**Post date:** [September 5, 2020, 4:40pm UTC](https://discourse.processing.org/t/how-to-get-current-stroke-weight/23695/1 "2020-09-05T16:40:35Z")

</div>

I can set strokeWeight(x) but I can’t find a method to return the current weight.

---

<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:** [September 5, 2020, 4:56pm UTC](https://discourse.processing.org/t/how-to-get-current-stroke-weight/23695/2 "2020-09-05T16:56:57Z")

</div>

you can store it every time you use strokeWeight(x)

you can even write a function for this like

before `setup()`: `float currentStrokeWeight;`

function:

```auto
void strokeWeightMy( float x) {
   strokeWeight(x) ;
   currentStrokeWeight=x; 
}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 5, 2020, 5:17pm UTC](https://discourse.processing.org/t/how-to-get-current-stroke-weight/23695/3 "2020-09-05T17:17:49Z")

</div>

> [@mr\_riptano](#):
>
> … but I can’t find a method to return the current weight.

There’s no method for it but a field within the PGraphics class named _strokeWeight_:  
[Processing.GitHub.io/processing-javadocs/core/processing/core/PGraphics.html#strokeWeight](http://Processing.GitHub.io/processing-javadocs/core/processing/core/PGraphics.html#strokeWeight)

Access the PGraphics main canvas via PApplet::_g_ field or PApplet::**getGraphics()** method:  
[Processing.GitHub.io/processing-javadocs/core/processing/core/PApplet.html#g](http://Processing.GitHub.io/processing-javadocs/core/processing/core/PApplet.html#g)  
[Processing.GitHub.io/processing-javadocs/core/processing/core/PApplet.html#getGraphics--](http://Processing.GitHub.io/processing-javadocs/core/processing/core/PApplet.html#getGraphics--)

```auto
println(g.strokeWeight); // 1.0
strokeWeight(2.5);
println(getGraphics().strokeWeight); // 2.5
exit();

```

---

<div class="post-metadata">

**Author:** ![mr\_riptano](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mr\_riptano](https://discourse.processing.org/u/mr_riptano)\
**Post date:** [September 5, 2020, 6:24pm UTC](https://discourse.processing.org/t/how-to-get-current-stroke-weight/23695/4 "2020-09-05T18:24:41Z")

</div>

Thanks! Follow on question: g.strokeColor is just a single int, how do I get r/g/b/a which is also an option to stroke() ?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 5, 2020, 6:29pm UTC](https://discourse.processing.org/t/how-to-get-current-stroke-weight/23695/5 "2020-09-05T18:29:23Z")

</div>

1. [Processing.org/reference/red\_.html](http://Processing.org/reference/red_.html)
2. [Processing.org/reference/green\_.html](http://Processing.org/reference/green_.html)
3. [Processing.org/reference/blue\_.html](http://Processing.org/reference/blue_.html)
4. [Processing.org/reference/alpha\_.html](http://Processing.org/reference/alpha_.html)
