# How does the red() function work

**URL:** <https://discourse.processing.org/t/how-does-the-red-function-work/25687>\
**Category:** Beginners\
**Created:** [November 25, 2020, 6:41am UTC](https://discourse.processing.org/t/how-does-the-red-function-work/25687 "2020-11-25T06:41:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PyroDeathAdder](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@PyroDeathAdder](https://discourse.processing.org/u/PyroDeathAdder)\
**Post date:** [November 25, 2020, 6:41am UTC](https://discourse.processing.org/t/how-does-the-red-function-work/25687/1 "2020-11-25T06:41:47Z")

</div>

i was just wondering what processing does so it can do red(colorObject) and return the red value of that color

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [November 25, 2020, 8:05am UTC](https://discourse.processing.org/t/how-does-the-red-function-work/25687/2 "2020-11-25T08:05:33Z")

</div>

A color is an integer number of 32 bits ordered as AAAAAAAARRRRRRRRGGGGGGGGBBBBBBBB where the A’s contain the alpha value, the R’s are the red value, G’s are green, and B’s are blue.  
The red() function extracts the R component of this number and scales it to the colorMode() value.  
If you are using the default colorMode 255 value, you can use bit shifting which makes it easier to understand how the individual colors are extracted. See:

> **[\>\> (right shift) \\ Language (API) \\ Processing 3+](https://processing.org/reference/rightshift.html)**

---

<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:** [November 25, 2020, 2:05pm UTC](https://discourse.processing.org/t/how-does-the-red-function-work/25687/3 "2020-11-25T14:05:05Z")

</div>

Hello,

Resources:

> **[color \\ Language (API) \\ Processing 3+](https://processing.org/reference/color_datatype.html)**

You can also print these values:

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

There are references, tutorials and examples here:

_[processing.org](http://processing.org)_

Not always easy to find stuff… enjoy the search and you learn along the way.

`:)`
