# Declare and use array of colors

**URL:** <https://discourse.processing.org/t/declare-and-use-array-of-colors/30785>\
**Category:** Beginners\
**Created:** [June 18, 2021, 9:45pm UTC](https://discourse.processing.org/t/declare-and-use-array-of-colors/30785 "2021-06-18T21:45:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yalaniv](https://avatars.discourse-cdn.com/v4/letter/y/7993a0/32.png) [@yalaniv](https://discourse.processing.org/u/yalaniv)\
**Post date:** [June 18, 2021, 9:45pm UTC](https://discourse.processing.org/t/declare-and-use-array-of-colors/30785/1 "2021-06-18T21:45:00Z")

</div>

I have a list of rgb colors.  
I want to store them in an array,  
and while running, choose randomly index.

since the fill function require 3 numbers,  
I wonder how to declare it and use it

---

<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:** [June 18, 2021, 9:49pm UTC](https://discourse.processing.org/t/declare-and-use-array-of-colors/30785/2 "2021-06-18T21:49:14Z")

</div>

color[] listCol = new color[5];

fill(listCol[index]);

---

<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:** [June 18, 2021, 10:15pm UTC](https://discourse.processing.org/t/declare-and-use-array-of-colors/30785/3 "2021-06-18T22:15:01Z")

</div>

> [@yalaniv](#):
>
> since the fill function require 3 numbers,  
> I wonder how to declare it and use it

“Wonder is the beginning of wisdom.” - Socrates

The Processing website has resources (tutorials, references and examples) here:  
[https://processing.org/](https://processing.org/)

The fill() function accepts:

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

Reference for the _color_ datatype:  
_[color / Reference / Processing.org](https://www.processing.org/reference/color_datatype.html)_

Example:

```auto
color c = #FF00FF; //Fuchsia

color[] col = {
              color(255, 0, 0), // Red
              0xFF00FF00, // Green
              #0000FF, // Blue
              c
              };

```

`:)`
