aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-02-13 01:35:56 +0100
committerDuncaen <mail@duncano.de>2017-02-13 01:35:56 +0100
commit297e98d72661b0f895dfc65342cfed3ff780a183 (patch)
treef46c13fac2f19e615f272c3058d47a2950bada95
parent5eafdce461abbc8f1d34fd0d530c08bb883b5bc1 (diff)
downloaddotfiles-297e98d72661b0f895dfc65342cfed3ff780a183.tar.gz
bin: add hex2rgb and rgb2hex
-rwxr-xr-xbin/hex2rgb9
-rwxr-xr-xbin/rgb2hex3
2 files changed, 12 insertions, 0 deletions
diff --git a/bin/hex2rgb b/bin/hex2rgb
new file mode 100755
index 0000000..d911bef
--- /dev/null
+++ b/bin/hex2rgb
@@ -0,0 +1,9 @@
+#!/bin/sh
+# hex2rgb [hex ...] - converts hex colors to rgb
+for x; do
+ case "$x" in \#*) x=${x#*#};; esac
+ a=$(echo "$x" | cut -c-2)
+ b=$(echo "$x" | cut -c3-4)
+ c=$(echo "$x" | cut -c5-6)
+ printf "%d %d %d\n" "0x$a" "0x$b" "0x$c"
+done
diff --git a/bin/rgb2hex b/bin/rgb2hex
new file mode 100755
index 0000000..d838029
--- /dev/null
+++ b/bin/rgb2hex
@@ -0,0 +1,3 @@
+#!/bin/sh
+# rgb2hex red green blue - converts rgb to hex colors
+printf "#%02x%02x%02x\n" $@