# Gradient does not work

**URL:** <https://discourse.processing.org/t/gradient-does-not-work/29347>\
**Category:** Coding Questions\
**Created:** [April 13, 2021, 6:54pm UTC](https://discourse.processing.org/t/gradient-does-not-work/29347 "2021-04-13T18:54:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaspervb](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jaspervb/32/10571_2.png) [@jaspervb](https://discourse.processing.org/u/jaspervb)\
**Post date:** [April 13, 2021, 6:54pm UTC](https://discourse.processing.org/t/gradient-does-not-work/29347/1 "2021-04-13T18:54:56Z")

</div>

Hi There,

I want to make a gradient in processing with a for loop.  
I can not figure out how i can solve this.

```auto
void setup() {
  color from = color(255, 165, 32);
  color to = color(72, 61, 139);
  int steps = 100;
  int w = 300 / steps;
  
  size(300, 300);
  background(51);
  noStroke();
  
  for (int i = 0; i < steps; i++) {
    fill(lerpColor(from, to, ..?... ));
    rect(i * w, 0, w, height);
  }
}

```

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [April 13, 2021, 7:24pm UTC](https://discourse.processing.org/t/gradient-does-not-work/29347/2 "2021-04-13T19:24:38Z")

</div>

`map(i, 0, steps, 0, 1)` ?

---

<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 13, 2021, 7:40pm UTC](https://discourse.processing.org/t/gradient-does-not-work/29347/3 "2021-04-13T19:40:43Z")

</div>

Hello,

Like this?  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/24a47ac6403ca977f8ff91494922988cda24a99b.png)

> [@jaspervb](#):
>
> `..?... `

This needs to be a float between 0 an 1.

i/?

Make sure ? is a floating point number so the result is a float.  
Integer math (int/int) gives the result as an integer (you lose the decimal points).

10 is an integer  
10.0 is a float

`:)`
