Converts a simple list of color definitions to asset catalogs for Xcode and resource XML for Android
Find a file
2020-12-31 18:47:37 +01:00
.github/workflows Set git user name/email 2020-12-31 00:09:39 +01:00
.swiftpm/xcode Add initial code 2020-12-30 10:54:13 +01:00
Sources Output alpha as hex value as well to asset catalogs 2020-12-31 18:47:37 +01:00
Tests/MakeColorsTests SwiftLint 2020-12-30 13:35:21 +01:00
.gitattributes Ignore github workflows on export 2020-12-30 20:47:24 +01:00
.gitignore Add initial code 2020-12-30 10:54:13 +01:00
.swift-version Configure + run SwiftFormat 2020-12-30 12:53:40 +01:00
.swiftformat Configure + run SwiftFormat 2020-12-30 12:53:40 +01:00
.swiftlint.yml SwiftLint 2020-12-30 13:35:21 +01:00
LICENSE Add my full name to license 2020-12-30 10:55:42 +01:00
Makefile Create Makefile 2020-12-30 23:09:21 +01:00
Package.resolved Add initial code 2020-12-30 10:54:13 +01:00
Package.swift Configure + run SwiftFormat 2020-12-30 12:53:40 +01:00
README.md Add homebrew installation instructions to readme 2020-12-30 23:59:34 +01:00

MakeColors

Converts a simple list of color definitions to asset catalogs for Xcode, resource XML for Android or an HTML preview.

Installation

Install via Homebrew:

brew tap 5sw/makecolors
brew install make-colors

Input format

Each line in your input contains one color definition. That is a name followed by the actual color. We support RGB colors in a few formats similar to CSS:

Color/Color1 #fff
Color/Color2 #abcdeff0
Color/Color3 rgb(12, 13, 53)
Color/Color4 rgba(250, 250, 250, 128)

Colors can also reference other colors by prefixing them with an @ sign:

ColorAlias @Color/Color1

Output format

Xcode Asset Catalogs (--ios)

The optional prefix followed by a / is added in front of the color name. Then for each part separate by / a new folder that provides namespace is inserted in the asset catalogs. Spaces are inserted between CamelCase words. Color references are inserted as copies of the original color.

Android resource XML (--android)

The optional prefix, followed by a underscore is added in front of the name. Names are converted from CamelCase to snake_case and / is replaced by underscores as well. Color references the generated color resource also references the original color.

HTML preview (--html)

Generates a simple HTML table with the color names, values and a sample.

Future work

  • Support other color formats (HSV, ...)
  • Calculate derived colors (blend, change hue/saturation/brightness/alpha)
  • Support for dark/light mode
  • Improved error reporting in the parser