Changeset 1808
- Timestamp:
- Jul 17, 2007, 7:20:11 PM (15 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/transform.c
r1807 r1808 32 32 static uint32_t leftchar(uint32_t ch); 33 33 static uint32_t rightchar(uint32_t ch); 34 static void leftpair(uint32_t pair[2]); 35 static void rightpair(uint32_t pair[2]); 34 36 35 37 /** \brief Invert a canvas' colours. … … 364 366 for(x = 0; x < subwidth; x++) 365 367 { 366 uint32_t ch1, ch2, attr1, attr2;367 368 ch1= cv->chars[(subwidth * y + x) * 2];368 uint32_t pair[2], attr1, attr2; 369 370 pair[0] = cv->chars[(subwidth * y + x) * 2]; 369 371 attr1 = cv->attrs[(subwidth * y + x) * 2]; 370 ch2= cv->chars[(subwidth * y + x) * 2 + 1];372 pair[1] = cv->chars[(subwidth * y + x) * 2 + 1]; 371 373 attr2 = cv->attrs[(subwidth * y + x) * 2 + 1]; 372 374 373 newchars[(subheight * (subwidth - 1 - x) + y) * 2] = ch1; 375 leftpair(pair); 376 377 newchars[(subheight * (subwidth - 1 - x) + y) * 2] = pair[0]; 374 378 newattrs[(subheight * (subwidth - 1 - x) + y) * 2] = attr1; 375 newchars[(subheight * (subwidth - 1 - x) + y) * 2 + 1] = ch2;379 newchars[(subheight * (subwidth - 1 - x) + y) * 2 + 1] = pair[1]; 376 380 newattrs[(subheight * (subwidth - 1 - x) + y) * 2 + 1] = attr2; 377 381 } … … 554 558 for(x = 0; x < subwidth; x++) 555 559 { 556 uint32_t ch1, ch2, attr1, attr2;557 558 ch1= cv->chars[(subwidth * y + x) * 2];560 uint32_t pair[2], attr1, attr2; 561 562 pair[0] = cv->chars[(subwidth * y + x) * 2]; 559 563 attr1 = cv->attrs[(subwidth * y + x) * 2]; 560 ch2= cv->chars[(subwidth * y + x) * 2 + 1];564 pair[1] = cv->chars[(subwidth * y + x) * 2 + 1]; 561 565 attr2 = cv->attrs[(subwidth * y + x) * 2 + 1]; 562 566 563 newchars[(subheight * x + subheight - 1 - y) * 2] = ch1; 567 rightpair(pair); 568 569 newchars[(subheight * x + subheight - 1 - y) * 2] = pair[0]; 564 570 newattrs[(subheight * x + subheight - 1 - y) * 2] = attr1; 565 newchars[(subheight * x + subheight - 1 - y) * 2 + 1] = ch2;571 newchars[(subheight * x + subheight - 1 - y) * 2 + 1] = pair[1]; 566 572 newattrs[(subheight * x + subheight - 1 - y) * 2 + 1] = attr2; 567 573 } … … 902 908 '<', 'v', '>', '^', 903 909 ',', '.', '\'', '`', 910 /* ASCII / Unicode */ 911 '(', 0x203f, ')', 0x2040, /* ( ‿ ) ⁀ */ 904 912 /* Misc Unicode */ 905 913 0x256d, 0x2570, 0x256f, 0x256e, /* ╭ ╰ ╯ ╮ */ … … 954 962 } 955 963 964 static uint32_t const leftright2x2[] = 965 { 966 /* ASCII / Unicode */ 967 '-', '-', 0x4e28, CUCUL_MAGIC_FULLWIDTH, /* -- 丨 */ 968 0, 0, 0, 0 969 }; 970 971 static uint32_t const leftright2x4[] = 972 { 973 /* ASCII */ 974 ':', ' ', '.', '.', ' ', ':', '\'', '\'', 975 /* ASCII / Unicode */ 976 ' ', '`', 0x00b4, ' ', 0x02ce, ' ', ' ', ',', /* ` ´ ˎ , */ 977 ' ', '`', '\'', ' ', '.', ' ', ' ', ',', 978 '`', ' ', ',', ' ', ' ', 0x00b4, ' ', 0x02ce, /* ` , ˎ ´ */ 979 '`', ' ', ',', ' ', ' ', '.', ' ', '\'', 980 '/', ' ', '-', 0x02ce, ' ', '/', '`', '-', /* / -ˎ / `- */ 981 '/', ' ', '-', '.', ' ', '/', '\'', '-', 982 '\\', ' ', ',', '-', ' ', '\\', '-', 0x00b4, /* \ ,- \ -´ */ 983 '\\', ' ', '.', '-', ' ', '\\', '-', '\'', 984 '|', ' ', '_', '_', ' ', '|', 0x203e, 0x203e, /* | __ | ‾‾ */ 985 '_', '|', 0x203e, '|', '|', 0x203e, '|', '_', /* _| ‾| |‾ |_ */ 986 '|', '_', '_', '|', 0x203e, '|', '|', 0x203e, /* |_ _| ‾| |‾ */ 987 '_', ' ', ' ', 0x2577, ' ', 0x203e, 0x2575, ' ', /* _ ╷ ‾ ╵ */ 988 ' ', '_', ' ', 0x2575, 0x203e, ' ', 0x2577, ' ', /* _ ╵ ‾ ╷ */ 989 /* Not perfect, but better than nothing */ 990 ' ', '`', '\'', ' ', '.', ' ', ' ', ',', 991 '`', ' ', ',', ' ', ' ', '.', ' ', '\'', 992 0, 0, 0, 0, 0, 0, 0, 0 993 }; 994 995 static void leftpair(uint32_t pair[2]) 996 { 997 int i; 998 999 for(i = 0; leftright2x2[i]; i += 2) 1000 if(pair[0] == leftright2x2[i] && pair[1] == leftright2x2[i + 1]) 1001 { 1002 pair[0] = leftright2x2[(i & ~3) | ((i + 2) & 3)]; 1003 pair[1] = leftright2x2[((i & ~3) | ((i + 2) & 3)) + 1]; 1004 return; 1005 } 1006 1007 for(i = 0; leftright2x4[i]; i += 2) 1008 if(pair[0] == leftright2x4[i] && pair[1] == leftright2x4[i + 1]) 1009 { 1010 pair[0] = leftright2x4[(i & ~7) | ((i + 2) & 7)]; 1011 pair[1] = leftright2x4[((i & ~7) | ((i + 2) & 7)) + 1]; 1012 return; 1013 } 1014 } 1015 1016 static void rightpair(uint32_t pair[2]) 1017 { 1018 int i; 1019 1020 for(i = 0; leftright2x2[i]; i += 2) 1021 if(pair[0] == leftright2x2[i] && pair[1] == leftright2x2[i + 1]) 1022 { 1023 pair[0] = leftright2x2[(i & ~3) | ((i - 2) & 3)]; 1024 pair[1] = leftright2x2[((i & ~3) | ((i - 2) & 3)) + 1]; 1025 return; 1026 } 1027 1028 for(i = 0; leftright2x4[i]; i += 2) 1029 if(pair[0] == leftright2x4[i] && pair[1] == leftright2x4[i + 1]) 1030 { 1031 pair[0] = leftright2x4[(i & ~7) | ((i - 2) & 7)]; 1032 pair[1] = leftright2x4[((i & ~7) | ((i - 2) & 7)) + 1]; 1033 return; 1034 } 1035 } 1036 -
libcaca/trunk/test/text.c
r1805 r1808 26 26 27 27 #define STRING \ 28 " \n" \29 " _,----._ \n" \30 " (/ @ @ \\) \n" \31 " | OO | \n" \32 " \\ `--' / \n" \33 " `----' \n" \34 " \n" \35 " Hello world! \n" \36 " \n"28 " |_| \n" \ 29 " _,----._ | | \n" \ 30 " (/ @ @ \\) __ \n" \ 31 " | OO | |_ \n" \ 32 " \\ `--' / |__ \n" \ 33 " `----' \n" \ 34 " |_| \n" \ 35 " Hello world! | \n" \ 36 " \n" 37 37 38 38 int main(int argc, char *argv[]) … … 41 41 void *buffer; 42 42 unsigned long int len; 43 unsigned int i, j; 43 44 44 45 pig = cucul_create_canvas(0, 0); … … 65 66 cucul_get_canvas_height(pig), pig, NULL); 66 67 68 for(j = 0; j < cucul_get_canvas_height(cv); j++) 69 { 70 for(i = 0; i < cucul_get_canvas_width(cv); i += 2) 71 { 72 unsigned long int a; 73 cucul_set_color_ansi(cv, CUCUL_LIGHTBLUE + (i + j) % 6, 74 CUCUL_DEFAULT); 75 a = cucul_get_attr(cv, -1, -1); 76 cucul_put_attr(cv, i, j, a); 77 cucul_put_attr(cv, i + 1, j, a); 78 } 79 } 80 67 81 buffer = cucul_export_memory(cv, "utf8", &len); 68 82 fwrite(buffer, len, 1, stdout);
Note: See TracChangeset
for help on using the changeset viewer.