# CLOSED How to get current colorMode

**URL:** https://discourse.processing.org/t/closed-how-to-get-current-colormode/12812
**Category:** p5.js
**Created:** [July 19, 2019, 10:02am UTC](https://discourse.processing.org/t/closed-how-to-get-current-colormode/12812 "2019-07-19T10:02:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![monotone](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@monotone](https://discourse.processing.org/u/monotone)
#### Post date: [July 19, 2019, 10:02am UTC](https://discourse.processing.org/t/closed-how-to-get-current-colormode/12812/1 "2019-07-19T10:02:26Z")

</div>

Hi,

I try to get the current colorMode to adapt my code behaviour.  
But I didn’t found anyway to get it ?

I try colorMode() without params but nedd at list one.

Any idea ?

Thanks & regards,

Constant

---

<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: [July 19, 2019, 10:06am UTC](https://discourse.processing.org/t/closed-how-to-get-current-colormode/12812/2 "2019-07-19T10:06:00Z")

</div>

Can’t you set your own variable when you set your colormode?

Then your program can read this

eg boolean modeColor

or int colorModeIs = 3;

---

<div class="post-metadata">

### Author: ![monotone](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@monotone](https://discourse.processing.org/u/monotone)
#### Post date: [July 19, 2019, 10:09am UTC](https://discourse.processing.org/t/closed-how-to-get-current-colormode/12812/3 "2019-07-19T10:09:52Z")

</div>

Sure it’s a way to do, but first I wanted to make sur that it was not already by the framework.

Meanwhile I look at p5.Color source code and see that each color hold a mode attribute which is set to either constants.HSB/HSL/RGB.

So far, I can use that mode.

Thank’s

---

<div class="post-metadata">

### Author: ![monotone](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@monotone](https://discourse.processing.org/u/monotone)
#### Post date: [July 19, 2019, 11:22am UTC](https://discourse.processing.org/t/closed-how-to-get-current-colormode/12812/4 "2019-07-19T11:22:06Z")

</div>

constants.RGB.HSL/RGB is not available in global scope, so I’ll my own variable 🙂

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [July 20, 2019, 4:50pm UTC](https://discourse.processing.org/t/closed-how-to-get-current-colormode/12812/5 "2019-07-20T16:50:44Z")

</div>

I _believe_ this is true for p5.js because it was true in the original Processing(Java) API.

Currently, Java mode Processing has a generic way of doing style state checking, but it isn’t documented in the reference – the recommended way is to keep track of the settings before you set them. However, there is an alternative. getStyle() may be called on the g object (the canvas PGraphics) – this returns a PStyle object

[https://processing.github.io/processing-javadocs/core/processing/core/PStyle.html](https://processing.github.io/processing-javadocs/core/processing/core/PStyle.html)

which has a colorMode which can be checked (and imageMode, strokeColor, textSize, tint, et cetera)

```auto
PStyle ps = g.getStyle();
println(ps);
println(ps.colorMode);
colorMode(HSB);
ps = g.getStyle();
println(ps.colorMode);

```

I’m not sure if p5.js has a similar system – if it does I’m not aware of it.

---

<div class="post-metadata">

### Author: ![monotone](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@monotone](https://discourse.processing.org/u/monotone)
#### Post date: [July 23, 2019, 3:13pm UTC](https://discourse.processing.org/t/closed-how-to-get-current-colormode/12812/6 "2019-07-23T15:13:48Z")

</div>

Hi,

I don’t find the equivalent in p5js.

Thank’s for the suggestion.

Regards.
