Skip to content

Instantly share code, notes, and snippets.

@trieut
Last active December 17, 2015 07:19
Show Gist options
  • Save trieut/5572237 to your computer and use it in GitHub Desktop.
Save trieut/5572237 to your computer and use it in GitHub Desktop.
functions to calculate inverse hex colors (for html/css hacking)
#!/bin/bash
trimHash() {
x=$1
echo ${x:0:6}
}
hexToInt() {
let y=0x$1
echo $y
}
intToHex() {
prefix="000000"
hex=${prefix}$(printf '%x' $1)
echo ${hex: -6}
}
inverseInt() {
echo $((0xFFFFFF ^ $1))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment