Color string conversion color type problem.

I see a bit of code in the api documentation "const BANANA_YELLOW = "#FFE135". But I can't find a way to do that, like string to color type, or color type to string, right? Please help me.

  • Note: you might have more luck with a question like this in the "Discussion" area, but since nobody's replied, here goes...

    I think that's just an example of a string being used with const.

    If you just want to define a color in code, the easiest way is probably something like const BANANA_YELLOW = 0xFFE135.

    If you actually need to convert a string to a color, this might work, but I haven't tried it:

    var someColor = colorStr.substring(1, null).toNumberWithBase(16);


  • Thank you. I've already written an algorithm. Just convert the string to decimal one by one.