How to convert decimal color to hex color using toString(16) in open stage control?

Hi,
I'd like to automatically color a widget depending on the color information it receives from Ableton Live.

Ableton sends decimal values through AbletonOSC everytime a track color updates, and it looks like I can only use hex colors in Open Stage Control. I've looked up how to convert decimal colors to hex using Javascript and the easiest method seems to be (assuming the decimal is 16725558 for example):

16725558.toString(16)

I've been trying to get that to work in the 'colorFill' tab in the style properties of the widget that I want to change, but it hasn't worked yet. My current code in the 'colorFill' tab is:

##{@{this}.toString(16)}

The computed value this generates is: #16725558
So the .toString method hasn't done anything. I also tried it with a static example color instead of '@this' but that didn't work either. Does someone know how to solve this?

Thanks!

This should work actually if the widget's value is indeed a number, is there a chance it's sent as a string by ableton ? In which case you could cast to an integer before calling toString():

#{
  '#' + parseInt(@{this}).toString(16)
  // sligthly different syntax to avoid the confusing "##"
}
1 Like

yeah that worked! appreciate the quick reply :heavy_heart_exclamation: