# Question About color() function and colorMode()

**URL:** https://discourse.processing.org/t/question-about-color-function-and-colormode/41815
**Category:** Beginners
**Created:** [April 24, 2023, 8:02pm UTC](https://discourse.processing.org/t/question-about-color-function-and-colormode/41815 "2023-04-24T20:02:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![AnthonyMG](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@AnthonyMG](https://discourse.processing.org/u/AnthonyMG)
#### Post date: [April 24, 2023, 8:02pm UTC](https://discourse.processing.org/t/question-about-color-function-and-colormode/41815/1 "2023-04-24T20:02:29Z")

</div>

The color() function does not seem to work as I would have assumed. When executing the code below I get the following output:

```
"rgba(255,255,255,1)
levels c1: 255,255,255,255 
rgba(0,0,0,1)
levels c1: 0,0,0,255 "

```

I would expect the output to:

```
  1. Be the same for both print calls 
  2. Be the actual HSB color I put in the color() function, i.e (141,0,0), a dark red.

```

What gives?

[Link to sketch](https://editor.p5js.org/anthonymg/sketches/N3P6Hrku8)

same code below

```auto
function setup() {
  createCanvas(400, 400);
  colorMode(HSB,360,100,100)
}

function draw() {
  
  
  c1 = color('hsb(141,0,0)')
  c2 = color(141,0,0)
  print(c1 + "\nlevels c1: " + c1.levels)
  print(c2 + "\nlevels c1: " + c2.levels)
  noLoop()
}

```

---

<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: [April 24, 2023, 8:17pm UTC](https://discourse.processing.org/t/question-about-color-function-and-colormode/41815/2 "2023-04-24T20:17:07Z")

</div>

A [p5.Color](https://p5js.org/reference/#/p5.Color) object is always an RGBa value.  
Current [**colorMode()**](https://p5js.org/reference/#/p5/colorMode) is converted to its corresponding RGBa representation.
