# Are properties such as fill color, stroke weight, text size, etc. write only?

**URL:** <https://discourse.processing.org/t/are-properties-such-as-fill-color-stroke-weight-text-size-etc-write-only/33024>\
**Category:** Beginners\
**Created:** [October 23, 2021, 7:57pm UTC](https://discourse.processing.org/t/are-properties-such-as-fill-color-stroke-weight-text-size-etc-write-only/33024 "2021-10-23T19:57:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Math\_Machine](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@Math\_Machine](https://discourse.processing.org/u/Math_Machine)\
**Post date:** [October 23, 2021, 7:57pm UTC](https://discourse.processing.org/t/are-properties-such-as-fill-color-stroke-weight-text-size-etc-write-only/33024/1 "2021-10-23T19:57:28Z")

</div>

Hi, this is a question I’ve had on my mind for quite a while, and I apologize in advance if someone already asked it, but is there any way to just ask processing what the current stroke weight is? Or the current fill color, or the current text size, or the current stroke color, or the current rectangle mode, or the current text alignment, etc.? Or are these just write-only values, which can only be changed with a function and can only be obtained by knowing what they are at the beginning, and then manually changing them every time they change?

If it’s the latter, may I know what these values are by default at the start of any program? Especially textSize, all I can figure out is that it’s somewhere between 11 and 13 at the start of a program.

Thanks!

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 23, 2021, 8:06pm UTC](https://discourse.processing.org/t/are-properties-such-as-fill-color-stroke-weight-text-size-etc-write-only/33024/2 "2021-10-23T20:06:00Z")

</div>

Pretty sure it’s read only you can use variables if you want to read them.

---

<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:** [October 23, 2021, 8:56pm UTC](https://discourse.processing.org/t/are-properties-such-as-fill-color-stroke-weight-text-size-etc-write-only/33024/3 "2021-10-23T20:56:24Z")

</div>

If it’s only the text size you’re interested in, I can tell you that it’s 12. Says it right here in the source:

> <https://github.com/processing/processing/blob/a6a86250ffa4041b7d77fbb66dc02e78360c64f0/core/src/processing/core/PGraphics.java#L987>

If you rather want to keep track of those values (fill, stroke, …) at runtime, I don’t think there’s an easy way to do that. Not without accessing code you’re not supposed to touch and are prevented from doing so.  
You could create your own methods like `fillCustom` that just call `fill` under the hood and set a variable in the process, although that’s not an ideal solution either.

If that’s what you want I could go into more detail, but for now I just hope this helped you. 🙂

---

<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:** [October 23, 2021, 10:01pm UTC](https://discourse.processing.org/t/are-properties-such-as-fill-color-stroke-weight-text-size-etc-write-only/33024/4 "2021-10-23T22:01:11Z")

</div>

Hello,

Some insight I have gleaned from topics and _[Processing source code](https://github.com/processing)_:

```auto
// Attributes Read
// v1.0.0
// GLV 2021-10-22

//Defaults
println(g.strokeWeight);
println(g.textSize);
println(hex(g.fillColor));
println(g.stroke);
println(g.fill);

//Test
strokeWeight(1);
println(g.strokeWeight);

textSize(1);
println(g.textSize);

fill(0xFF00FF00);
println(hex(g.fillColor));

noStroke();
println(g.stroke);

noFill();
println(g.fill);

```

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

`:)`

---

<div class="post-metadata">

**Author:** ![Math\_Machine](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@Math\_Machine](https://discourse.processing.org/u/Math_Machine)\
**Post date:** [October 24, 2021, 3:19am UTC](https://discourse.processing.org/t/are-properties-such-as-fill-color-stroke-weight-text-size-etc-write-only/33024/5 "2021-10-24T03:19:49Z")

</div>

So then why does the code

```auto
text("Hello",width/2,height/2);
textSize(12);
text("Hello",width/2,height/2+20);

```

Produce two different looking strings of text?

---

<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:** [October 24, 2021, 9:48am UTC](https://discourse.processing.org/t/are-properties-such-as-fill-color-stroke-weight-text-size-etc-write-only/33024/6 "2021-10-24T09:48:16Z")

</div>

Hello @Math_Machine,

Good eye!

It may be related to the mode you are using.

Static mode:

> [@Math\_Machine](#):
>
> ```auto
> text("Hello",width/2,height/2);
> textSize(12);
> text("Hello",width/2,height/2+20);
> 
> ```

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

```auto
Active mode:

void setup() 
  {
  size(100, 100);
  println(g.textSize);
  text("Hello",width/2,height/2);
  textSize(12);
  text("Hello",width/2,height/2+20);
  }

```

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

There is a reference in the source code to:  
`g = createPrimaryGraphics();`

The defaults `g.*` may only apply to active mode with a setup() and draw()

Others may be able to comment with more clarity on this.

References:

- [https://github.com/processing/processing4/blob/master/core/src/processing/core/PApplet.java#L10365](https://github.com/processing/processing4/blob/master/core/src/processing/core/PApplet.java#L10365)
- [https://github.com/processing/processing4/blob/master/core/src/processing/core/PApplet.java#L2062](https://github.com/processing/processing4/blob/master/core/src/processing/core/PApplet.java#L2062)

Links above may take a moment to find the line in Google Chrome.

`:)`

---

<div class="post-metadata">

**Author:** ![Math\_Machine](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@Math\_Machine](https://discourse.processing.org/u/Math_Machine)\
**Post date:** [November 6, 2021, 7:19pm UTC](https://discourse.processing.org/t/are-properties-such-as-fill-color-stroke-weight-text-size-etc-write-only/33024/7 "2021-11-06T19:19:21Z")

</div>

Hey, so, how do I get vertical text align? Like, if I say “textAlign(LEFT, TOP)”, then ask to “println(g.textAlign)”, it’ll print out “LEFT”. What would I ask that would cause it to print “TOP”?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [June 19, 2022, 6:33am UTC](https://discourse.processing.org/t/are-properties-such-as-fill-color-stroke-weight-text-size-etc-write-only/33024/8 "2022-06-19T06:33:10Z")

</div>

Hi,

For getting both you can use  
g.textAlign and g.textAlignY

Cheers  
— mnse
