Initial import
This commit is contained in:
commit
3779fdce2c
48 changed files with 2012 additions and 0 deletions
34
themes/Makefile
Normal file
34
themes/Makefile
Normal file
|
@ -0,0 +1,34 @@
|
|||
# env
|
||||
# Written in 2019 by Lucas
|
||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all
|
||||
# copyright and related and neighboring rights to this software to the
|
||||
# public domain worldwide. This software is distributed without any
|
||||
# warranty. You should have received a copy of the CC0 Public Domain
|
||||
# Dedication along with this software. If not, see
|
||||
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
.POSIX:
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .in .txt .png
|
||||
|
||||
LDLIBS= -lm
|
||||
THEMES= blueie brightie brightie2 brightie3 brightie4
|
||||
|
||||
.c:
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
|
||||
|
||||
.in.txt:
|
||||
./colorscheme <"$<" >"$@"
|
||||
|
||||
.in.png:
|
||||
./colorscheme -i <"$<" | pnmtopng >"$@"
|
||||
|
||||
all: colorscheme
|
||||
|
||||
clean:
|
||||
rm -f colorscheme $(THEMES:=.png) $(THEMES:=.txt)
|
||||
|
||||
show: $(THEMES:=.png) $(THEMES:=.txt)
|
||||
|
||||
$(THEMES:=.png) $(THEMES:=.txt): all
|
19
themes/blueie.in
Normal file
19
themes/blueie.in
Normal file
|
@ -0,0 +1,19 @@
|
|||
rgbhex 00 00 11
|
||||
rgbhex 00 00 11
|
||||
rgbhex cc 22 22
|
||||
rgbhex 22 88 22
|
||||
rgbhex dd aa 44
|
||||
rgbhex 22 66 cc
|
||||
rgbhex 99 66 cc
|
||||
rgbhex 66 aa dd
|
||||
rgbhex cc cc cc
|
||||
|
||||
rgbhex ff ff ee
|
||||
rgbhex 33 33 44
|
||||
rgbhex ff 22 22
|
||||
rgbhex 44 cc 44
|
||||
rgbhex ff cc 44
|
||||
rgbhex 44 88 ff
|
||||
rgbhex cc 66 ff
|
||||
rgbhex 88 cc ff
|
||||
rgbhex ff ff ff
|
18
themes/brightie-old
Normal file
18
themes/brightie-old
Normal file
|
@ -0,0 +1,18 @@
|
|||
XTerm.VT100.color0: #000000
|
||||
XTerm.VT100.color1: #99503d
|
||||
XTerm.VT100.color2: #4f993d
|
||||
XTerm.VT100.color3: #99873d
|
||||
XTerm.VT100.color4: #3d5099
|
||||
XTerm.VT100.color5: #993d87
|
||||
XTerm.VT100.color6: #3d8799
|
||||
XTerm.VT100.color7: #bfbfbf
|
||||
XTerm.VT100.color8: #404040
|
||||
XTerm.VT100.color9: #ff5c33
|
||||
XTerm.VT100.color10: #5cff33
|
||||
XTerm.VT100.color11: #ffd633
|
||||
XTerm.VT100.color12: #335cff
|
||||
XTerm.VT100.color13: #ff33d6
|
||||
XTerm.VT100.color14: #33d6ff
|
||||
XTerm.VT100.color15: #ffffff
|
||||
XTerm.VT100.foreground: #fffcf2
|
||||
XTerm.VT100.background: #0d0a00
|
19
themes/brightie.in
Normal file
19
themes/brightie.in
Normal file
|
@ -0,0 +1,19 @@
|
|||
hsv 48 1.0 0.05
|
||||
hsv 0 0.0 0.0
|
||||
hsv 12 0.6 0.6
|
||||
hsv 108 0.6 0.6
|
||||
hsv 48 0.6 0.6
|
||||
hsv 228 0.6 0.6
|
||||
hsv 312 0.6 0.6
|
||||
hsv 192 0.6 0.6
|
||||
hsv 0 0.0 0.75
|
||||
|
||||
hsv 48 0.05 1.0
|
||||
hsv 0 0.0 0.25
|
||||
hsv 12 0.8 1.0
|
||||
hsv 108 0.8 1.0
|
||||
hsv 48 0.8 1.0
|
||||
hsv 228 0.8 1.0
|
||||
hsv 312 0.8 1.0
|
||||
hsv 192 0.8 1.0
|
||||
hsv 0 0.0 1.0
|
19
themes/brightie2.in
Normal file
19
themes/brightie2.in
Normal file
|
@ -0,0 +1,19 @@
|
|||
hsv 48 1.0 0.05
|
||||
hsv 0 0.0 0.0
|
||||
hsv 12 1.0 0.6
|
||||
hsv 108 1.0 0.6
|
||||
hsv 48 1.0 0.6
|
||||
hsv 228 1.0 0.6
|
||||
hsv 312 1.0 0.6
|
||||
hsv 192 1.0 0.6
|
||||
hsv 0 0.0 0.75
|
||||
|
||||
hsv 48 0.05 1.0
|
||||
hsv 0 0.0 0.25
|
||||
hsv 12 0.8 1.0
|
||||
hsv 108 0.8 1.0
|
||||
hsv 48 0.8 1.0
|
||||
hsv 228 0.8 1.0
|
||||
hsv 312 0.8 1.0
|
||||
hsv 192 0.8 1.0
|
||||
hsv 0 0.0 1.0
|
19
themes/brightie3.in
Normal file
19
themes/brightie3.in
Normal file
|
@ -0,0 +1,19 @@
|
|||
hsv 48 1.0 0.05
|
||||
hsv 0 0.0 0.0
|
||||
hsv 12 1.0 0.7
|
||||
hsv 108 1.0 0.7
|
||||
hsv 48 1.0 0.7
|
||||
hsv 228 1.0 0.7
|
||||
hsv 312 1.0 0.7
|
||||
hsv 192 1.0 0.7
|
||||
hsv 0 0.0 0.7
|
||||
|
||||
hsv 48 0.05 1.0
|
||||
hsv 0 0.0 0.25
|
||||
hsv 12 0.8 1.0
|
||||
hsv 108 0.8 1.0
|
||||
hsv 48 0.8 1.0
|
||||
hsv 228 0.8 1.0
|
||||
hsv 312 0.8 1.0
|
||||
hsv 192 0.8 1.0
|
||||
hsv 0 0.0 1.0
|
19
themes/brightie4.in
Normal file
19
themes/brightie4.in
Normal file
|
@ -0,0 +1,19 @@
|
|||
hsv 48 1.0 0.05
|
||||
hsv 0 0.0 0.0
|
||||
hsv 12 1.0 0.8
|
||||
hsv 108 1.0 0.8
|
||||
hsv 48 1.0 0.8
|
||||
hsv 228 1.0 0.8
|
||||
hsv 312 1.0 0.8
|
||||
hsv 192 1.0 0.8
|
||||
hsv 0 0.0 0.8
|
||||
|
||||
hsv 48 0.05 1.0
|
||||
hsv 0 0.0 0.2
|
||||
hsv 12 0.8 1.0
|
||||
hsv 108 0.8 1.0
|
||||
hsv 48 0.8 1.0
|
||||
hsv 228 0.8 1.0
|
||||
hsv 312 0.8 1.0
|
||||
hsv 192 0.8 1.0
|
||||
hsv 0 0.0 1.0
|
198
themes/colorscheme.c
Normal file
198
themes/colorscheme.c
Normal file
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
* env
|
||||
* Written in 2019 by Lucas
|
||||
* CC0 1.0 Universal/Public domain - No rights reserved
|
||||
*
|
||||
* To the extent possible under law, the author(s) have dedicated all
|
||||
* copyright and related and neighboring rights to this software to the
|
||||
* public domain worldwide. This software is distributed without any
|
||||
* warranty. You should have received a copy of the CC0 Public Domain
|
||||
* Dedication along with this software. If not, see
|
||||
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define LENGTH 50
|
||||
|
||||
#define INRANGE(x, a, b) ((a) <= (x) && (x) <= (b))
|
||||
|
||||
static void
|
||||
hsvtorgb(double hsv[3], uint8_t rgb[3])
|
||||
{
|
||||
double c, hh, m, x;
|
||||
double r, g, b;
|
||||
|
||||
c = hsv[2] * hsv[1];
|
||||
hh = hsv[0] / 60.0;
|
||||
x = c * (1.0 - fabs(fmod(hh, 2.0) - 1.0));
|
||||
|
||||
switch ((int)floor(hh == 6.0 ? 0.0 : hh)) {
|
||||
case 0: r = c; g = x; b = 0; break;
|
||||
case 1: r = x; g = c; b = 0; break;
|
||||
case 2: r = 0; g = c; b = x; break;
|
||||
case 3: r = 0; g = x; b = c; break;
|
||||
case 4: r = x; g = 0; b = c; break;
|
||||
case 5: r = c; g = 0; b = x; break;
|
||||
}
|
||||
|
||||
m = hsv[2] - c;
|
||||
r += m; g += m; b += m;
|
||||
|
||||
rgb[0] = round(255 * r);
|
||||
rgb[1] = round(255 * g);
|
||||
rgb[2] = round(255 * b);
|
||||
}
|
||||
|
||||
static void
|
||||
hsltorgb(double hsl[3], uint8_t rgb[3])
|
||||
{
|
||||
double c, hh, m, x;
|
||||
double r, g, b;
|
||||
|
||||
c = (1.0 - fabs(2.0 * hsl[2] - 1.0)) * hsl[1];
|
||||
hh = hsl[0] / 60.0;
|
||||
x = c * (1.0 - fabs(fmod(hh, 2.0) - 1.0));
|
||||
|
||||
switch ((int)floor(hh == 6.0 ? 0.0 : hh)) {
|
||||
case 0: r = c; g = x; b = 0; break;
|
||||
case 1: r = x; g = c; b = 0; break;
|
||||
case 2: r = 0; g = c; b = x; break;
|
||||
case 3: r = 0; g = x; b = c; break;
|
||||
case 4: r = x; g = 0; b = c; break;
|
||||
case 5: r = c; g = 0; b = x; break;
|
||||
}
|
||||
|
||||
m = hsl[2] - c / 2.0;
|
||||
r += m; g += m; b += m;
|
||||
|
||||
rgb[0] = round(255 * r);
|
||||
rgb[1] = round(255 * g);
|
||||
rgb[2] = round(255 * b);
|
||||
}
|
||||
|
||||
static void
|
||||
parsecolorline(const char *s, size_t n, uint8_t rgb[3])
|
||||
{
|
||||
double d[3];
|
||||
unsigned int u[3];
|
||||
|
||||
if (sscanf(s, "hsv %lf %lf %lf", &d[0], &d[1], &d[2]) == 3) {
|
||||
if (!INRANGE(d[0], 0, 360) || !INRANGE(d[1], 0, 1)
|
||||
|| !INRANGE(d[2], 0, 1))
|
||||
goto err;
|
||||
hsvtorgb(d, rgb);
|
||||
} else if (sscanf(s, "hsl %lf %lf %lf", &d[0], &d[1], &d[2]) == 3) {
|
||||
if (!INRANGE(d[0], 0, 360) || !INRANGE(d[1], 0, 1)
|
||||
|| !INRANGE(d[2], 0, 1))
|
||||
goto err;
|
||||
hsltorgb(d, rgb);
|
||||
} else if (sscanf(s, "rgb %u %u %u", &u[0], &u[1], &u[2]) == 3) {
|
||||
if (!INRANGE(u[0], 0, 255) || !INRANGE(u[1], 0, 255)
|
||||
|| !INRANGE(u[2], 0, 255))
|
||||
goto err;
|
||||
rgb[0] = u[0]; rgb[1] = u[1]; rgb[2] = u[2];
|
||||
} else if (sscanf(s, "rgbhex %x %x %x", &u[0], &u[1], &u[2]) == 3) {
|
||||
if (!INRANGE(u[0], 0, 255) || !INRANGE(u[1], 0, 255)
|
||||
|| !INRANGE(u[2], 0, 255))
|
||||
goto err;
|
||||
rgb[0] = u[0]; rgb[1] = u[1]; rgb[2] = u[2];
|
||||
} else {
|
||||
err:
|
||||
fprintf(stderr, "Invalid input: \"%s\".", s);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
readcolorscheme(uint8_t colorscheme[18][3])
|
||||
{
|
||||
char *line = NULL;
|
||||
size_t linesize = 0;
|
||||
ssize_t linelen;
|
||||
int nlines = 0;
|
||||
|
||||
while ((linelen = getline(&line, &linesize, stdin)) != -1
|
||||
&& nlines < 18) {
|
||||
if (linelen == 0 || line[0] == '\n' || line[0] == '#')
|
||||
continue;
|
||||
parsecolorline(line, linelen, colorscheme[nlines]);
|
||||
nlines++;
|
||||
}
|
||||
free(line);
|
||||
if (ferror(stdin)) {
|
||||
fputs("Input error.\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
if (nlines < 18) {
|
||||
fputs("Not enought colors.\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
writecolor(uint8_t rgb[3], int l)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < l; i++) {
|
||||
if (fwrite(rgb, sizeof(rgb[0]), 3, stdout) != 3) {
|
||||
fputs("Short write.\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_image(uint8_t colorscheme[18][3])
|
||||
{
|
||||
int i, n;
|
||||
|
||||
printf("P6\n%u %u 255\n", 9 * LENGTH, 2 * LENGTH);
|
||||
for (i = 0; i < LENGTH; i++)
|
||||
for (n = 0; n < 9; n++)
|
||||
writecolor(colorscheme[n], LENGTH);
|
||||
for (i = 0; i < LENGTH; i++)
|
||||
for (n = 9; n < 18; n++)
|
||||
writecolor(colorscheme[n], LENGTH);
|
||||
}
|
||||
|
||||
static void
|
||||
do_colors(uint8_t colorscheme[18][3])
|
||||
{
|
||||
int n;
|
||||
for (n = 0; n < 18; n++)
|
||||
printf("#%02x%02x%02x\n", colorscheme[n][0],
|
||||
colorscheme[n][1], colorscheme[n][2]);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
uint8_t colorscheme[18][3];
|
||||
int iflag = 0;
|
||||
|
||||
if (argc > 2)
|
||||
goto usage;
|
||||
if (argc == 2) {
|
||||
if (strncmp(argv[1], "-i", 3) != 0)
|
||||
goto usage;
|
||||
iflag = 1;
|
||||
}
|
||||
|
||||
readcolorscheme(colorscheme);
|
||||
|
||||
if (iflag)
|
||||
do_image(colorscheme);
|
||||
else
|
||||
do_colors(colorscheme);
|
||||
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
fprintf(stderr, "Usage: %s [-i]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
27
themes/showcase.sh
Normal file
27
themes/showcase.sh
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
# env
|
||||
# Written in 2019 by Lucas
|
||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all
|
||||
# copyright and related and neighboring rights to this software to the
|
||||
# public domain worldwide. This software is distributed without any
|
||||
# warranty. You should have received a copy of the CC0 Public Domain
|
||||
# Dedication along with this software. If not, see
|
||||
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s theme-name [theme-name...]\n" "${0##*/}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
make
|
||||
for theme; do
|
||||
if [ ! -f "$theme".in ]; then
|
||||
printf "%s: No \"%s.in\" file.\n" "${0##*}" "$theme" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./colorscheme <"$theme".in >"$theme".txt
|
||||
./colorscheme -i <"$theme".in | pnmtopng >"$theme".png
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue