colors

extract colors from pictures
git clone git://git.2f30.org/colors
Log | Files | Refs | README | LICENSE

commit 21e5f9472c2bfdb87f4e1f47e2d5d57ac7196827
parent 35730be563a8a505a99293e72135ce475db73513
Author: sin <sin@2f30.org>
Date:   Tue,  9 Jun 2015 15:12:13 +0100

Add hex2col by z3bra

Diffstat:
Abin/hex2col.c | 24++++++++++++++++++++++++
1 file changed, 24 insertions(+), 0 deletions(-)

diff --git a/bin/hex2col.c b/bin/hex2col.c @@ -0,0 +1,24 @@ +/* only works in xterm, written by z3bra */ + +#include <stdio.h> +#include <string.h> + +int +main (int argc, char **argv) +{ + char hexcode[8], shortcode[2]; + int i, rgb[3]; + + while (read(0, hexcode, 8) > 0) { + hexcode[7] = 0; + for (i=0; i<3; i++) { + strncpy(shortcode, hexcode + 1 + 2*i, 2); + rgb[i] = strtol(shortcode, NULL, 16); + } + printf("[48;2;%d;%d;%dm%8s ", rgb[0],rgb[1],rgb[2], ""); + printf("[38;2;%d;%d;%dm%s\n", rgb[0],rgb[1],rgb[2], hexcode); + } + + printf(""); + return 0; +}