Dynamic Color Backgrounds

Posts: 36
Hello all,

I'm trying to understand how I can have assigned colors to show up as driver ticker backgrounds in various places.
Specifically, I have a spreadsheet loaded with all the color codes for every driver. Is there an easy way to pull this information so I can color backgrounds or numbers that color?
I know there's an option to pull the iracing paint colors. Is there a way to attach the color to the color code in a spreadsheet?

Thanks a bunch for any help!
Scott
Posts: 72
Use the "override background color" option on whatever widgets/subwidgets/labels you want the color to be on. For the data binding, select the column of the spreadsheet where the color codes are. Add this script to your theme and select it as a converter script on the override background color:

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using System.Windows.Media;

namespace Scripts
{
public class HexConvert : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var colorString = value?.ToString();
if (string.IsNullOrWhiteSpace(colorString))
return Color.FromRgb(153,0,0);

return (Color)ColorConverter.ConvertFromString(colorString);
}
}
}


That will convert the hex code in the spreadsheet to a background color.
Posts: 36
Thank you so much for your time with this, Josh!

I copied that text and added it as a new script. At the top of that page, I'm getting a "compilation error".
Also, my spreadsheet color codes are loaded in the spreadsheet, but they're still not showing up on the overlay.
Unfortunately I don't know much about that coding to be able to diagnose it. Any idea what I may be doing wrong?
Thank you so much, man!
Scott
Posts: 72
What is the compilation error saying? You can find it on the bottom of the window.

The one error I can think of that might be happening is the name is incorrect - make sure the name of the script is "HexConvert"

If it's not an error with the name, I am honestly not sure. If you get the error fixed with that and the colors still don't show, make sure you have the colors in the hex format - #000000 as an example.
Posts: 36
Yes, that did it! It was the naming problem. Just needed to name the script correctly.
Thank you so much!!
Posts: 72
Of course Scott! Just a note I remembered - the fallback color is set to a dark red (153,0,0). Change those numbers in the first "return" to whatever you want the fallback color to be.
Posts: 36
I was just logging in to ask you about the red. Thanks a bunch!
Scott
Posts: 36
Hi Josh!
I’m running into some issues with this script drastically slowing down performance, to where it’s unusable.
I have tested the theme without the script and seems to work great. My question is, is the there a way to simplify it maybe so that there’re no backup color?
Basically, it’s just a race of 16 assigned drivers. Every one of them have an assigned hex color.
Just tryin to think of ways to simplify it in hopes of improving the performance.
Thanks soo much for your time, Josh!
Scott
Posts: 72
This will just display nothing if no color is found:

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using System.Windows.Media;

namespace Scripts
{
public class StringToColorConverter : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var colorString = value?.ToString();
if (string.IsNullOrWhiteSpace(colorString))
return Colors.Transparent;

return (Color)ColorConverter.ConvertFromString(colorString);
}
}
}
Posts: 72
***You'll have to change the "StringToColorConverter" to "HexConvert" :D