# HSB resolution Question

**URL:** https://discourse.processing.org/t/hsb-resolution-question/29735
**Category:** Coding Questions
**Created:** [April 29, 2021, 9:27pm UTC](https://discourse.processing.org/t/hsb-resolution-question/29735 "2021-04-29T21:27:12Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![IRIGIMA](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/irigima/32/8951_2.png) [@IRIGIMA](https://discourse.processing.org/u/IRIGIMA)
#### Post date: [April 29, 2021, 9:27pm UTC](https://discourse.processing.org/t/hsb-resolution-question/29735/1 "2021-04-29T21:27:12Z")

</div>

Using HSB colour mode, does anyone know the correct resolution / setting for each without any internal calculations??  
Example: colorMode(HSB, 45,97,43) would cause a conversion when reading / writing values respective to actual correct HSB settings in colorMode.

I’m expecting:  
H= 0 \> 255  
S= 0 \> 255  
B= 0 \> 255

As this would make sense in RGB mode ??  
But Hue ranges from 0\>359. Can we display all 360 hues or is this internally altered to 0 \> 255 ??

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [April 29, 2021, 9:58pm UTC](https://discourse.processing.org/t/hsb-resolution-question/29735/2 "2021-04-29T21:58:16Z")

</div>

I’m not sure to understand your question but the second and further arguments of the `colorMode()` function is the range of the values you input in color.

So if you write `colorMode(HSB, 360, 100, 100)`, the hue will be a value from 0 to 360 and Saturation and Brightness from 0 to 100.

Here is the reference: [colorMode() \ Language (API) \ Processing 3+](https://processing.org/reference/colorMode_.html)

---

<div class="post-metadata">

### Author: ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)
#### Post date: [April 29, 2021, 10:04pm UTC](https://discourse.processing.org/t/hsb-resolution-question/29735/3 "2021-04-29T22:04:01Z")

</div>

To understand HSB (Hue, Saturation, Brightness), it’s best to play with a colour mixer, like the one in GIMP:

 ![colour-gimp-mixer-red](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/189e819d795da3060551f9421ed3d1fa768b5e81.png)

The Hue values lie along the ring that surrounds the triangle – hence, they range from 0 to 360 degrees. The Saturation (S) and Brightness (V) values range between 0 and 100 percent.

Typically, you’d use this code for red:

```auto
colorMode(HSB, 360, 100, 100);
background(360, 100, 100);

```

The `colorMode()` defines the ranges for each H/S/B parameter. For a red background, the Hue value points to East, and the Saturation and Brightness are set to 100%.

For the colour ‘opposite’ to red (the pale blue), it’s `background(180, 100, 100)`

---

<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: [April 30, 2021, 1:46am UTC](https://discourse.processing.org/t/hsb-resolution-question/29735/4 "2021-04-30T01:46:54Z")

</div>

Hello,

Some references on Processing website:

- [Color \ Processing.org](https://processing.org/tutorials/color/)
- [color() \ Language (API) \ Processing 3+](https://www.processing.org/reference/color_.html)
- [colorMode() \ Language (API) \ Processing 3+](https://processing.org/reference/colorMode_.html)
- Many others in references

On Medium:

- [Color Gradients in Processing (v 2.0) | by Jeremy Behreandt | Medium](https://behreajj.medium.com/color-gradients-in-processing-v-2-0-e5c0b87cdfd2)

Examples on Processing website and in Processing PDE:

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

The Processing PDE has a Color Selector in the Tools menu:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c3bd60248b9414cc9b666372542b1fa1ca03a3f0.jpeg)

`:)`

---

<div class="post-metadata">

### Author: ![IRIGIMA](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/irigima/32/8951_2.png) [@IRIGIMA](https://discourse.processing.org/u/IRIGIMA)
#### Post date: [April 30, 2021, 4:08pm UTC](https://discourse.processing.org/t/hsb-resolution-question/29735/5 "2021-04-30T16:08:18Z")

</div>

Thanks all for your info.  
I fully understand HSV and RGB externally (conversions etc)

Am just interested in how colours are stored in PGraphics.

On initial question using HSV,  
H= 0 \> 359  
S= 0 \> 100  
B= 0 \> 100

Gives 3.6 million combinations

RGB  
R= 0 \> 255  
G= 0 \> 255  
B= 0 \> 255

Gives 16.6 million combinations

What is the highest setting for HSB which uses all combinations in the PGraphics array (24 bit etc).  
(As setting H to 3600 will results in loss in array)  
RGB usually has a 0 \> 255 range, and setting higher to 2550,2550,2550 would waste definition due to PGraphics limit.

What is this limit

I’ve seen a post here mentioning internal reading / write HSB conversions resulting in jumps in increment / decrement.

So using RGB now as easier to control.  
Far better results.

Here are some low-res images using original HSB settings. Currently rendering with new RGB.

Thanks again!!

Irigima.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/9f492d45cd6fdb60a832b32eba56fe26ba681a7e.jpeg) ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7628fa6beecfad9a816d53e5484196fe03bc9ba7.jpeg)

---

<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 3, 2021, 1:08am UTC](https://discourse.processing.org/t/hsb-resolution-question/29735/7 "2021-05-03T01:08:14Z")

</div>

You had me thinking about this!

I did this and put it in the gallery:

> [@HSB Color Gradient](https://discourse.processing.org/t/hsb-color-gradient/29795):
>
> HSB color gradient sweeping through hue with 100% saturation and 100% brightness. I have done similar with loops for RGB colorMode() and this is the same outcome (close) with HSB colorMode. I wanted to use integers and sweep through all the possible combinations at 100% sat and 100% brightness in integer steps as part of this exploration. // HSB Gradient Exploration // v1.0.0 // GLV 2021-05-01 int hue = 1536; //256\*6 hue combinations; actually 3x triplets are identical so 256\*6 - 6! int coun…

`:)`

---

<div class="post-metadata">

### Author: ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)
#### Post date: [May 3, 2021, 7:24am UTC](https://discourse.processing.org/t/hsb-resolution-question/29735/8 "2021-05-03T07:24:58Z")

</div>

It’s internally calculated as float so the range shouldn’t matter

> <https://github.com/processing/processing/blob/a6e0e227a948e7e2dc042c04504d6f5b8cf0c1a6/core/src/processing/core/PGraphics.java#L7716>

---

<div class="post-metadata">

### Author: ![IRIGIMA](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/irigima/32/8951_2.png) [@IRIGIMA](https://discourse.processing.org/u/IRIGIMA)
#### Post date: [May 3, 2021, 7:29pm UTC](https://discourse.processing.org/t/hsb-resolution-question/29735/9 "2021-05-03T19:29:31Z")

</div>

Such an amazing amount of technical input from you all.  
Thank you.

I am actually reverting back to RGB now (0\>255) as easier to function / control.

Holding a count per pixel externally reflecting PGraphics (but not limited as PGraphics), then applying a scale, resulting in  
768 combinations per pixel.  
N (scaled to 768)  
R=N  
G=N-256  
B=N-512

(Black\>Red\>Yellow\>White)

Works really well.

r/Irigima
