# Fill from an array

**URL:** <https://discourse.processing.org/t/fill-from-an-array/38080>\
**Category:** Beginners\
**Created:** [July 24, 2022, 7:40pm UTC](https://discourse.processing.org/t/fill-from-an-array/38080 "2022-07-24T19:40:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ablanton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ablanton/32/16683_2.png) [@ablanton](https://discourse.processing.org/u/ablanton)\
**Post date:** [July 24, 2022, 7:40pm UTC](https://discourse.processing.org/t/fill-from-an-array/38080/1 "2022-07-24T19:40:57Z")

</div>

hi all,

i’m trying to input fill() from a global array and can’t see why this won’t work. it looks like a type conversion issue, but i thought this should work. any hints?

```auto
let array_main = ['0fb794', 2, 3];

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  
  print("'#"+array_main[0]+"'");
  fill("'#"+array_main[0]+"'"); //This dosen't work
  //fill('#0fb794' ); //This works
  triangle(30, 75, 58, 20, 86, 75);
}

```

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [July 24, 2022, 8:00pm UTC](https://discourse.processing.org/t/fill-from-an-array/38080/2 "2022-07-24T20:00:08Z")

</div>

Try:  
`fill("#"+array_main[0]);`

---

<div class="post-metadata">

**Author:** ![ablanton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ablanton/32/16683_2.png) [@ablanton](https://discourse.processing.org/u/ablanton)\
**Post date:** [July 24, 2022, 8:07pm UTC](https://discourse.processing.org/t/fill-from-an-array/38080/3 "2022-07-24T20:07:41Z")

</div>

that works! thank you, i knew i was missing something 😵‍💫

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [July 24, 2022, 8:25pm UTC](https://discourse.processing.org/t/fill-from-an-array/38080/4 "2022-07-24T20:25:03Z")

</div>

Hi @ablanton,

Why not putting the hash(#) direct in array initialisation and afterwards just do …

```auto
fill(array_main[0]); 

```

?

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![ablanton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ablanton/32/16683_2.png) [@ablanton](https://discourse.processing.org/u/ablanton)\
**Post date:** [July 24, 2022, 8:40pm UTC](https://discourse.processing.org/t/fill-from-an-array/38080/5 "2022-07-24T20:40:06Z")

</div>

oh, this is just a quick example, in the work i’m slicing a longer string and then putting it into the array. so it’s quicker to concatenate the # in the fill function
