Setting colours in code
In Python colours are simply defined by a list of three numbers, representing red, green and blue on a scale of -1 to +1.
Online you have to define a colour object using these three numbers. Builder components make this conversion automatically. However, if you are setting a colour in code then the Python pologon.setFillColor("white")
would need to be manually translated into pologon.setFillColor(new util.Color("white"))
To avoid this manual translation, I create colour objects in a Both code component in my setup routine.
For example:
Python
white = "white"
grey = [0, 0, 0]
transparent = None;
JavaScript
white = new util.Color("white");
grey = new util.Color([0, 0, 0]);
transparent = null;
Then polygon.setFillColor(white) or text.setColor(grey) will work in an Auto translated code component.