sprite-enhalfen tool

This commit is contained in:
nick black 2019-12-18 08:16:36 -05:00
parent 37ed8300cb
commit 4a7409ebda
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 237 additions and 99 deletions

View File

@ -5,104 +5,109 @@
//2 = yellow
//3 = green
static const char luigi1[] = "0000000000000000"
"0000000000000000"
"0000000111110000"
"0000011111120000"
"0000111111220000"
"0000111111111110"
"0000333223222000"
"0003223223322220"
"0003223322222222"
"0033223322232222"
"0033222223333330"
"0003322222333330"
"0000032222222200"
"0000311122200000"
"0003133313000000"
"0003133331300000"
"0033133333112200"
"0031133333332222"
"0031113333332222"
"0001113333333222"
"0001111333333222"
"0001111113331000"
"0001111111111000"
"0001111111113000"
"3333111111131100"
"3333111113311100"
"3333111131111000"
"3333111001111000"
"3333000003333000"
"3300000003333000"
"3000000003333330"
"0000000003333330";
static const char* luigis[] = {
"0000000000000000"
"0000000000000000"
"0000000111110000"
"0000011111120000"
"0000111111220000"
"0000111111111110"
"0000333223222000"
"0003223223322220"
"0003223322222222"
"0033223322232222"
"0033222223333330"
"0003322222333330"
"0000032222222200"
"0000311122200000"
"0003133313000000"
"0003133331300000"
"0033133333112200"
"0031133333332222"
"0031113333332222"
"0001113333333222"
"0001111333333222"
"0001111113331000"
"0001111111111000"
"0001111111113000"
"3333111111131100"
"3333111113311100"
"3333111131111000"
"3333111001111000"
"3333000003333000"
"3300000003333000"
"3000000003333330"
"0000000003333330",
static const char luigi2[] = "0000000000000000"
"0000001111100000"
"0000111111200000"
"0001111112200000"
"0001111111111100"
"0003332232220000"
"0032232233222200"
"0032233222222220"
"0332233222322220"
"0332222233333300"
"0033222223333300"
"0003322222222000"
"0000111122000000"
"0003133113300000"
"0031333311300000"
"0031333311330000"
"0031333311130000"
"0031333332230000"
"0031333322220000"
"0011133322221000"
"0011133322221100"
"0011113322211100"
"0011111133111100"
"0001111133311000"
"0000111333333000"
"0000113333330000"
"0000011333300000"
"0000031113330000"
"0000033330330000"
"0000333330000000"
"0000333333300000"
"0000003333300000";
"0000000000000000"
"0000001111100000"
"0000111111200000"
"0001111112200000"
"0001111111111100"
"0003332232220000"
"0032232233222200"
"0032233222222220"
"0332233222322220"
"0332222233333300"
"0033222223333300"
"0003322222222000"
"0000111122000000"
"0003133113300000"
"0031333311300000"
"0031333311330000"
"0031333311130000"
"0031333332230000"
"0031333322220000"
"0011133322221000"
"0011133322221100"
"0011113322211100"
"0011111133111100"
"0001111133311000"
"0000111333333000"
"0000113333330000"
"0000011333300000"
"0000031113330000"
"0000033330330000"
"0000333330000000"
"0000333333300000"
"0000003333300000",
"0000001111100000"
"0000111111200000"
"0001111112200000"
"0001111111111100"
"0003332232220000"
"0032232233222200"
"0032233222222220"
"0332233222322220"
"0332222233333300"
"0333222223333300"
"0003322222222000"
"0000033322000000"
"0000111133100020"
"0003333113310222"
"0033333311313222"
"0333333311331222"
"0333333311331323"
"0333333111331330"
"3333331112132300"
"3333111111111000"
"2222211111111000"
"2222211111111003"
"2222111111111033"
"0222111111133333"
"0001311111133333"
"0031131111133333"
"3331113311133333"
"3333111100033333"
"3333310000000000"
"0333000000000000"
"0333000000000000"
"0033300000000000",
NULL
};
static const char luigi3[] = "0000001111100000"
"0000111111200000"
"0001111112200000"
"0001111111111100"
"0003332232220000"
"0032232233222200"
"0032233222222220"
"0332233222322220"
"0332222233333300"
"0333222223333300"
"0003322222222000"
"0000033322000000"
"0000111133100020"
"0003333113310222"
"0033333311313222"
"0333333311331222"
"0333333311331323"
"0333333111331330"
"3333331112132300"
"3333111111111000"
"2222211111111000"
"2222211111111003"
"2222111111111033"
"0222111111133333"
"0001311111133333"
"0031131111133333"
"3331113311133333"
"3333111100033333"
"3333310000000000"
"0333000000000000"
"0333000000000000"
"0033300000000000";
static int
draw_luigi(struct ncplane* n, const char* sprite){
@ -169,11 +174,9 @@ int luigi_demo(struct notcurses* nc){
return -1;
}
lastseen = lns[i];
draw_luigi(lns[i], luigis[i]);
ncplane_move_bottom(lastseen); // all start hidden underneath stdplane
}
draw_luigi(lns[0], luigi1);
draw_luigi(lns[1], luigi2);
draw_luigi(lns[2], luigi3);
struct timespec stepdelay;
ns_to_timespec(timespec_to_ns(&demodelay) / (cols - 16 - 1), &stepdelay);
for(i = 0 ; i < cols - 16 - 1 ; ++i){

135
src/poc/sprite-enhalfen.c Normal file
View File

@ -0,0 +1,135 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static const char* luigis[] = {
"0000000000000000"
"0000000000000000"
"0000000111110000"
"0000011111120000"
"0000111111220000"
"0000111111111110"
"0000333223222000"
"0003223223322220"
"0003223322222222"
"0033223322232222"
"0033222223333330"
"0003322222333330"
"0000032222222200"
"0000311122200000"
"0003133313000000"
"0003133331300000"
"0033133333112200"
"0031133333332222"
"0031113333332222"
"0001113333333222"
"0001111333333222"
"0001111113331000"
"0001111111111000"
"0001111111113000"
"3333111111131100"
"3333111113311100"
"3333111131111000"
"3333111001111000"
"3333000003333000"
"3300000003333000"
"3000000003333330"
"0000000003333330",
"0000000000000000"
"0000001111100000"
"0000111111200000"
"0001111112200000"
"0001111111111100"
"0003332232220000"
"0032232233222200"
"0032233222222220"
"0332233222322220"
"0332222233333300"
"0033222223333300"
"0003322222222000"
"0000111122000000"
"0003133113300000"
"0031333311300000"
"0031333311330000"
"0031333311130000"
"0031333332230000"
"0031333322220000"
"0011133322221000"
"0011133322221100"
"0011113322211100"
"0011111133111100"
"0001111133311000"
"0000111333333000"
"0000113333330000"
"0000011333300000"
"0000031113330000"
"0000033330330000"
"0000333330000000"
"0000333333300000"
"0000003333300000",
"0000001111100000"
"0000111111200000"
"0001111112200000"
"0001111111111100"
"0003332232220000"
"0032232233222200"
"0032233222222220"
"0332233222322220"
"0332222233333300"
"0333222223333300"
"0003322222222000"
"0000033322000000"
"0000111133100020"
"0003333113310222"
"0033333311313222"
"0333333311331222"
"0333333311331323"
"0333333111331330"
"3333331112132300"
"3333111111111000"
"2222211111111000"
"2222211111111003"
"2222111111111033"
"0222111111133333"
"0001311111133333"
"0031131111133333"
"3331113311133333"
"3333111100033333"
"3333310000000000"
"0333000000000000"
"0333000000000000"
"0033300000000000",
NULL
};
static int
enhalfen(const char* s, int width){
if(strlen(s) % (width * 2)){
fprintf(stderr, "Bad length: %zu\n", strlen(s));
return -1;
}
size_t rowoff = 0;
size_t idx;
for(rowoff = 0 ; s[rowoff] ; rowoff += 2 * width){
for(idx = 0 ; idx < width ; ++idx){
int c = (s[rowoff + idx] - '0') * 4 + (s[rowoff + width + idx] - '0');
printf("%x", c);
}
printf("\n");
}
return 0;
}
int main(void){
const char** sprite;
for(sprite = luigis ; *sprite ; ++sprite){
if(enhalfen(*sprite, 16)){
return EXIT_FAILURE;
}
printf("\n");
}
return EXIT_SUCCESS;
}