# Color translation

**URL:** <https://forum.inductiveautomation.com/t/color-translation/5281>\
**Category:** Ignition\
**Created:** [October 16, 2012, 7:51pm UTC](https://forum.inductiveautomation.com/t/color-translation/5281 "2012-10-16T19:51:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [October 16, 2012, 7:51pm UTC](https://forum.inductiveautomation.com/t/color-translation/5281/1 "2012-10-16T19:51:24Z")

</div>

[code]import colorsys, system

colorRaw = system.tag.read("[Client]color1").value  
color = colorRaw[0] / 255.0 , colorRaw[1] / 255.0 , colorRaw[2] / 255.0  
new1 = colorsys.rgb\_to\_hls(color[0], color[1], color[2])  
new2 = colorsys.hls\_to\_rgb(float(new1[0]) + 0.3, new1[1], new1[2])  
new3 = colorsys.hls\_to\_rgb(float(new1[0]) + 0.6, new1[1], new1[2])  
color2 = str(int(round(new2[0] \* 255))) + ‘,’ + str(int(round(new2[1] \* 255))) + ‘,’ + str(int(round(new2[1] \* 255)))  
color3 = str(int(round(new3[0] \* 255))) + ‘,’ + str(int(round(new3[1] \* 255))) + ‘,’ + str(int(round(new3[1] \* 255)))  
system.tag.write("[Client]color2", color2)  
system.tag.write("[Client]color3", color3)[/code]

I’m attemping to create 3 primary colors from a xxx,xxx,xxx string input.  
This works in the script playground if i use colorRaw = x,y,z  
Can’t seem to figure out what I have wrong so I can’t use this in a client tag change script.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [October 16, 2012, 8:00pm UTC](https://forum.inductiveautomation.com/t/color-translation/5281/2 "2012-10-16T20:00:50Z")

</div>

It worked in the script playground because you were creating a tuple, which is handled differently than a string. You’ll want to use split(",") on the value you get back from the client tag in order to get the same effect.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [October 16, 2012, 8:11pm UTC](https://forum.inductiveautomation.com/t/color-translation/5281/3 "2012-10-16T20:11:01Z")

</div>

`#colorRaw = system.tag.read("[Client]color1").value
import colorsys, system
input = newValue.value
colorRaw = input.split(",")
color = float(colorRaw[0]) / 255.0 , float(colorRaw[1]) / 255.0 , float(colorRaw[2]) / 255.0
new1 = colorsys.rgb_to_hls(color[0], color[1], color[2])
new2 = colorsys.hls_to_rgb(float(new1[0]) + 0.1, new1[1], new1[2])
new3 = colorsys.hls_to_rgb(float(new1[0]) + 0.2, new1[1], new1[2])
color2 = str(int(round(new2[0] * 255))) + ',' + str(int(round(new2[1] * 255))) + ',' + str(int(round(new2[1] * 255)))
color3 = str(int(round(new3[0] * 255))) + ',' + str(int(round(new3[1] * 255))) + ',' + str(int(round(new3[1] * 255)))
system.tag.write("[Client]color2", color2)
system.tag.write("[Client]color3", color3)`

Thanks. Here is the script working.  
This is my code now,  
And I have my color custom properties of my window bound to color2 and color3 client tags… Still doesn’t change those values

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [October 16, 2012, 8:27pm UTC](https://forum.inductiveautomation.com/t/color-translation/5281/4 "2012-10-16T20:27:02Z")

</div>

Are you getting any errors in the diagnostic console of the client? Or is it just not functioning properly?

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [October 17, 2012, 2:50pm UTC](https://forum.inductiveautomation.com/t/color-translation/5281/5 "2012-10-17T14:50:38Z")

</div>

[quote=“BigSchottkyD”]  
And I have my color custom properties of my window bound to color2 and color3 client tags… Still doesn’t change those values[/quote]

I didn’t mean this…  
Everything works fine… Now I have to figure out how to choose a reasonable range of colors to use this with.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [October 17, 2012, 3:29pm UTC](https://forum.inductiveautomation.com/t/color-translation/5281/6 "2012-10-17T15:29:10Z")

</div>

Ok great, glad you got it working. I’ll shut this one down.
