1
0
mirror of https://github.com/fumiama/CMoe-Counter.git synced 2025-02-25 22:08:45 +01:00

优化显示长度

This commit is contained in:
源文雨 2022-03-02 17:58:19 +08:00
parent df36f7b9fd
commit 65f7583c2f
2 changed files with 3 additions and 3 deletions

4
cmoe.c
View File

@ -89,7 +89,7 @@ static uint32_t get_content_len(int isbig, uint16_t* len_type, char* cntstr) {
+ 16 + isbig + 16 + isbig
+ sizeof(svg_tail) - 1; + sizeof(svg_tail) - 1;
for(int i = 0; cntstr[i]; i++) { for(int i = 0; cntstr[i]; i++) {
len += len_type[cntstr[i] - '0'] + (sizeof(img_slot_front) + sizeof(img_slot_rear) - 1); len += len_type[cntstr[i] - '0'] + (sizeof(img_slot_front) + sizeof(img_slot_rear) - 2);
} }
return len; return len;
} }
@ -149,7 +149,7 @@ static void return_count(char* name, char* theme) {
printf(img_slot_front, w * i, w, h); printf(img_slot_front, w * i, w, h);
int n = cntstr[i] - '0'; int n = cntstr[i] - '0';
fwrite(theme_type[n], len_type[n], 1, stdout); fwrite(theme_type[n], len_type[n], 1, stdout);
puts(img_slot_rear); printf(img_slot_rear);
} }
fflush(stdout); fflush(stdout);
write(1, svg_tail, sizeof(svg_tail)-1); write(1, svg_tail, sizeof(svg_tail)-1);

2
cmoe.h
View File

@ -50,7 +50,7 @@ const char svg_big[] =
" <g>\n" " <g>\n"
" \n"; " \n";
const char img_slot_front[] = " <image x=\"%d\" y=\"0\" width=\"%d\" height=\"%d\" xlink:href=\""; const char img_slot_front[] = " <image x=\"%d\" y=\"0\" width=\"%d\" height=\"%d\" xlink:href=\"";
const char img_slot_rear[] = "\"></image>"; const char img_slot_rear[] = "\"></image>\n";
const char svg_tail[] = const char svg_tail[] =
" </g>\n" " </g>\n"
"</svg>"; "</svg>";