Skip to content

Instantly share code, notes, and snippets.

@illarionov
Created August 15, 2016 13:06
Show Gist options
  • Save illarionov/a8cd1b50d74ac0ef20bf10d8b2913fb9 to your computer and use it in GitHub Desktop.
Save illarionov/a8cd1b50d74ac0ef20bf10d8b2913fb9 to your computer and use it in GitHub Desktop.
UIColor(red:0.643, green:0.549, blue:0.839, alpha: 1) -> ffa48cd6
#!/bin/sh
#Usage: echo 'UIColor(red:0.643, green:0.549, blue:0.839, alpha: 1)' | uicolor2argb
perl -nle 'if (/UIColor\(red\:\s*(\S+)\,\s*green:\s*(\S+)\,\s*blue:\s*(\S+),\s*alpha:\s*(\S)/) { printf "%02x%02x%02x%02x\n", 0.5+255*$4, 0.5 + 255 * $1, 0.5+255*$2, 0.5+255*$3}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment