# Have an error with change color line when I want to change some of them in particular state

**URL:** <https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011>\
**Category:** Questions\
**Tags:** material\
**Created:** [July 31, 2020, 6:48am UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011 "2020-07-31T06:48:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [July 31, 2020, 6:48am UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011/1 "2020-07-31T06:48:56Z")

</div>

Hello Everyone

I am trying to change the color of some lines, but I got an error , is it possible to help me solve it?  
this is my PG:  
[https://playground.babylonjs.com/#FRJX06#17](https://playground.babylonjs.com/#FRJX06#17)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 31, 2020, 9:45am UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011/2 "2020-07-31T09:45:11Z")

</div>

You should not pass the `instance` parameter to `CreateLineSystem` as `lines` is not defined, and the `lineColors` variable should be an array of array, like `myLines`: you created a simple array instead.

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [July 31, 2020, 10:22am UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011/3 "2020-07-31T10:22:26Z")

</div>

Thank you @Evgeni_Popov, You are great.  
I have done it as you said, but the problem is all the line change to red, But I want just the line[i].AU that are bigger than 5 changed to red and rest of them be green. where is my mistake?  
[https://playground.babylonjs.com/#FRJX06#21](https://playground.babylonjs.com/#FRJX06#21)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 31, 2020, 11:55am UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011/4 "2020-07-31T11:55:02Z")

</div>

That’s because you used `line` instead of `entriesWithID` in your last loop:

[https://playground.babylonjs.com/#FRJX06#22](https://playground.babylonjs.com/#FRJX06#22)

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [July 31, 2020, 12:41pm UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011/5 "2020-07-31T12:41:23Z")

</div>

> [@Evgeni\_Popov](#):
>
> [https://playground.babylonjs.com/#FRJX06#22](https://playground.babylonjs.com/#FRJX06#22)

Thank you so much.

if I don’t want to have transition, and immediately changed greed to red , what should I use instead of BABYLON.Color4.Lerp ?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 31, 2020, 5:16pm UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011/6 "2020-07-31T17:16:59Z")

</div>

Colors are interpolated from previous vertex to current vertex. If you want a straight color change, you must duplicate the last vertex and assign the new color.

For eg, if you have 3 points with coordinates A, B and C and you want color red ® between A and B and blue (B) between B and C, you must really create 4 points in your line system [A,B,B,C], the corresponding colors being [R,R,B,B].

Note that your usage of Lerp is wrong because the 3rd value should be between 0 and 1. Anyway, I don’t think you want to use Lerp but instead push directly the color into the array.

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [July 31, 2020, 5:24pm UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011/7 "2020-07-31T17:24:22Z")

</div>

I have pushed color directly into array, But how can duplicate B point in my code?  
[https://playground.babylonjs.com/#FRJX06#25](https://playground.babylonjs.com/#FRJX06#25)

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 1, 2020, 7:56pm UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011/8 "2020-08-01T19:56:15Z")

</div>

> [@Arash\_Bagheri](#):
>
> [https://playground.babylonjs.com/#FRJX06#25](https://playground.babylonjs.com/#FRJX06#25)

Hi @Evgeni_Popov  
I’ve duplicate the points in line array but didn’t fix the problem.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 1, 2020, 8:24pm UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011/9 "2020-08-01T20:24:15Z")

</div>

You can try something like this:

[https://playground.babylonjs.com/#FRJX06#27](https://playground.babylonjs.com/#FRJX06#27)

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 2, 2020, 7:56am UTC](https://forum.babylonjs.com/t/have-an-error-with-change-color-line-when-i-want-to-change-some-of-them-in-particular-state/13011/10 "2020-08-02T07:56:44Z")

</div>

> [@Evgeni\_Popov](#):
>
> [https://playground.babylonjs.com/#FRJX06#27](https://playground.babylonjs.com/#FRJX06#27)

Thank you so much, its so great. 🙏 🙏
