Converts a vector drawable resource directory into a color resource file.
This is used to find and replace usages of colors in vector drawables (e.g., to force usage of colors in the Material Design spec only).
"Click to expand"
pip3 install -r requirements.txt
The command below will output a colors.xml
file in directory vectordrawableresdir2colorresfile
cd vectordrawableresdir2colorresfile
python3 vectordrawableresdir2colorresfile.py $project/app/src/main/res/drawable
To ensure the script has no external dependencies, an array and dictionary is used instead of input files.
If you want to use other color palettes:
python3 rgbcsv2colorarray.py @Material-Design-Color.palette.csv
Open output file rgbcsv2colorarray.py.txt
and paste content into vectordrawableresdir2colorresfile.py
python3 rgbcsv2colordict.py @Material-Design-Color.palette.csv
Open output file rgbcsv2colordict.py.txt
and paste content into vectordrawableresdir2colorresfile.py
To run the Python script you'll need:
- Python 3.6.0 or higher
Feel free to send us feedback by submitting an issue. Bug reports, feature requests, patches, and well-wishes are always welcome.
Note: Pull requests are welcome. For major changes, please submit an issue first to discuss what you would like to change.
- Optimized RGB-To-ColorName
- Modified rgbcsv2rgbarray.py
- Modified rgbcsv2colordict.py
Special thanks to Optimized RGB-To-ColorName for the algorithm that identifies the name of a color closest to an RGB value provided as input.