# lerpColor and float\[\] values do not seem to change

**URL:** <https://discourse.processing.org/t/lerpcolor-and-float-values-do-not-seem-to-change/5207>\
**Category:** Coding Questions\
**Created:** [November 5, 2018, 2:03am UTC](https://discourse.processing.org/t/lerpcolor-and-float-values-do-not-seem-to-change/5207 "2018-11-05T02:03:22Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![mhmmadeel](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mhmmadeel](https://discourse.processing.org/u/mhmmadeel)\
**Post date:** [November 5, 2018, 2:03am UTC](https://discourse.processing.org/t/lerpcolor-and-float-values-do-not-seem-to-change/5207/1 "2018-11-05T02:03:23Z")

</div>

Hi everyone 😊

I’m currently new to coding and am taking a class for it at a university.

I have a code running which is currently reading the data from the NYC Tree Census and loading svg’s of the leaf shape for the most frequent tree species as they appear in the CSV file. The size of the leaf is determined by how many of each tree species appears in the spreadsheet.

While this is working fine, I am trying to run code which also causes each leaf to change color according to health status of the tree. I have been attempting to use the lerpColor function and ascribing a value for each status as a float between 0 and 1. However, while the float array I have created is functioning, the values do not apply to the lerpColor function as I would have hoped. I have tried numerous methods and have spent hours reading through forums but I can’t seem to find anything that helps.

All of this is happening in a Leaf class which I then call on in my main sketch. This is the specific code related to my issue.

```auto
class Leaf {

  color worst, best;
  float[] lerpPosition;
  color finalColor;

Leaf(String filename, String searchterm ) {

    worst = color(255, 0, 0);
    best = color(0, 255, 0); 

    myLeafShape = loadShape(filename);

    lerpPosition = leafColor95().array();

}

 public FloatList leafColor95() {

    FloatList l = new FloatList();

    for (int i = 0; i < ninefive.getRowCount(); i += 1) {

      String species = ninefive.getString(i, "spc_common");
      String health = ninefive.getString(i, "health");

      if (species.indexOf(searchterm) != -1 && health.equals("Dead")) {
        l.append(0.1);
      } else if (species.indexOf(searchterm) != -1 && health.equals("Critical")) {
        l.append(0.2);
      } else if (species.indexOf(searchterm) != -1 && health.equals("Poor")) {
        l.append(0.3);
      } else if (species.indexOf(searchterm) != -1 && health.equals("Fair")) {
        l.append(0.5);
      } else if (species.indexOf(searchterm) != -1 && health.equals("Good")) {
        l.append(0.7);
      } else if (species.indexOf(searchterm) != -1 && health.equals("Excellent")) {
        l.append(0.9);
      } else {
        println("NA");
      }
    }

    l.sort();
    return l;
  }

void changeColor() {

    for (float i : lerpPosition) {
      finalColor = lerpColor(worst, best, i);
    }
  }

  void update() {

    if (year == 1) {
      if (leafSize < numOfNinetyFive) {
        leafSize++;
      }
    }
  }

  void display() {

    da.shapeMode(CENTER); 
    changeColor();
    myLeafShape.setFill(color(finalColor)); 
    da.shape(myLeafShape, xPos, yPos, leafSize, leafSize);
  }
}

```

What I need to happen is for the color to update alongside leafSize, while right now the entire array loads correctly but the values do not seem to change accordingly.  
Thank you for your help! Sorry if this isn’t formatted correctly this is my first post but I’ll try my best to fix it accordingly.

---

_[View the full topic](https://discourse.processing.org/t/lerpcolor-and-float-values-do-not-seem-to-change/5207)._
