Closed DaRolla closed 7 years ago
You're totally right. I recently had some experience in Android development and found my color generation useless. It wouln't be hard to add that implementation by yourself as I explained on the readme, however I'll try to do it if I have some time.
Thanks for your response. I took a look at https://github.com/ment-mx/Prism#customization but I am missing some function giving me a hex with ARGB.
In format_HEX: your are using color.hex for RGB (alpha is missing). I wasn't able to find that function in order to modify it...
well, maybe we can use something like this:
format_ANDROID_XML: (color, commented) ->
formattedColor = '#' + parseInt(color.alpha,10).toString(16)).slice(-2) + parseInt(color.red,10).toString(16)).slice(-2) + parseInt(color.green,10).toString(16)).slice(-2) + parseInt(color.blue,10).toString(16)).slice(-2);
if commented
"#{formattedColor} // #{color.name}"
else
formattedColor
Yep, the method toString(16) is useful to convert decimal into hexadecimal. However if you have a decimal number that converts into a one digit hexadecimal number, for example:
0 is also 0 in hexadecimal.
Then you would have a problem, as you need a leading 0 to complete the alpha component.
That's the only problem you need to solve. The rest of the hexadecimal numbers you need (RGB) are easy to get by just calling color.hex
.
Also, parseInt() is not something you need. color.alpha
gives you a 0 to 1 value that you can convert to a 0-255 value you need by just doing: color.alpha * 255
Sorry for the delay, I've been a little busy lately.
I have added support for Android XML in the last release ;) Hope you like it.
Thanks a lot, I will have a try...
Hi there,
thanks for your plugin. I am an Android developer, and I want to tell you our needs.
In Android it is very common to place the assets next to the code. So colors are defined in XML. Your export only suits the JAVA code, not the XML.
In more details we need something like this: https://developer.android.com/samples/BasicMediaRouter/res/values/colors.html
Maybe you can help us?
Greetings, DaRolla