diff options
author | June McEnroe <programble@gmail.com> | 2018-04-02 13:53:20 -0400 |
---|---|---|
committer | June McEnroe <programble@gmail.com> | 2018-04-02 13:53:20 -0400 |
commit | 426f9fdcfd979be776d5a480a823f25ce234d8d8 (patch) | |
tree | 7ec5ca01a5d08d7a0be376c05547519549c249e2 /bin | |
parent | Add HSV output to scheme (diff) | |
download | src-426f9fdcfd979be776d5a480a823f25ce234d8d8.tar.gz src-426f9fdcfd979be776d5a480a823f25ce234d8d8.zip |
Use uint32_t for len in scheme
There are potentially 256 colours.
Diffstat (limited to '')
-rw-r--r-- | bin/scheme.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/bin/scheme.c b/bin/scheme.c index df69b903..2c2c575b 100644 --- a/bin/scheme.c +++ b/bin/scheme.c @@ -65,7 +65,7 @@ static void pngChunk(const char *type, uint32_t size) { } enum { NONE, SUB, UP, AVERAGE, PAETH }; -static void png(const struct Hsv *scheme, uint8_t len) { +static void png(const struct Hsv *scheme, uint32_t len) { uint32_t swatchWidth = 64; uint32_t swatchHeight = 64; uint32_t columns = 8; @@ -82,7 +82,7 @@ static void png(const struct Hsv *scheme, uint8_t len) { pngInt(crc); pngChunk("PLTE", 3 * len); - for (uint8_t i = 0; i < len; ++i) { + for (uint32_t i = 0; i < len; ++i) { struct Rgb rgb = toRgb(scheme[i]); pngWrite(&rgb, 3); } @@ -93,7 +93,7 @@ static void png(const struct Hsv *scheme, uint8_t len) { for (uint32_t y = 0; y < height; ++y) { data[y][0] = (y % swatchHeight) ? UP : SUB; } - for (uint8_t i = 0; i < len; ++i) { + for (uint32_t i = 0; i < len; ++i) { uint32_t y = swatchHeight * (i / columns); uint32_t x = swatchWidth * (i % columns); data[y][1 + x] = x ? 1 : i; @@ -112,22 +112,22 @@ static void png(const struct Hsv *scheme, uint8_t len) { pngInt(crc); } -static void hsv(const struct Hsv *scheme, uint8_t len) { - for (uint8_t i = 0; i < len; ++i) { +static void hsv(const struct Hsv *scheme, uint32_t len) { + for (uint32_t i = 0; i < len; ++i) { printf("%g,%g,%g\n", scheme[i].h, scheme[i].s, scheme[i].v); } } -static void hex(const struct Hsv *scheme, uint8_t len) { - for (uint8_t i = 0; i < len; ++i) { +static void hex(const struct Hsv *scheme, uint32_t len) { + for (uint32_t i = 0; i < len; ++i) { struct Rgb rgb = toRgb(scheme[i]); printf("%02x%02x%02x\n", rgb.r, rgb.g, rgb.b); } } -static void linux(const struct Hsv *scheme, uint8_t len) { +static void linux(const struct Hsv *scheme, uint32_t len) { if (len > 16) len = 16; - for (uint8_t i = 0; i < len; ++i) { + for (uint32_t i = 0; i < len; ++i) { struct Rgb rgb = toRgb(scheme[i]); printf("\x1B]P%x%02x%02x%02x", i, rgb.r, rgb.g, rgb.b); } @@ -209,7 +209,7 @@ int main(int argc, char *argv[]) { struct Terminal terminal = genTerminal(ansi); const struct Hsv *scheme; - uint8_t len; + uint32_t len; switch (generate) { case ANSI: { scheme = (struct Hsv *)&ansi; |