Skip to content

Commit 6a71482

Browse files
committed
feat(outline): 实现描边不透明度配置项
1 parent ddb5118 commit 6a71482

File tree

4 files changed

+52
-31
lines changed

4 files changed

+52
-31
lines changed

AssFile/AssFile.c

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,10 +1154,14 @@ int writeAss(const char *const fileName, DANMAKU *danmakuHead,
11541154
"MarginL, MarginR, MarginV, Encoding\n"
11551155
);
11561156
char hexOpacity[3];
1157+
char hexOutlineOpacity[3];
11571158
char primaryColour[ASS_COLOR_LEN];
1159+
char outlineColour[ASS_COLOR_LEN];
11581160
int bold = 0;
11591161
toHexOpacity(255 - config.opacity, hexOpacity);
1162+
toHexOpacity(255 - config.outlineOpacity, hexOutlineOpacity);
11601163
sprintf(primaryColour, "&H%sFFFFFF", hexOpacity);
1164+
sprintf(outlineColour, "&H%s000000", hexOutlineOpacity);
11611165

11621166
if (config.bold == TRUE)
11631167
{
@@ -1171,42 +1175,36 @@ int writeAss(const char *const fileName, DANMAKU *danmakuHead,
11711175

11721176
/* 样式设定 */
11731177
fprintf(fptr, "\nStyle: %s,%s,%d,%s,%s,%s,%s,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.1f,%.1f,%d,%d,%d,%d,%d",
1174-
"R2L", config.fontname, config.fontsize, primaryColour, "&H00FFFFFF", "&H00000000", "&H1E6A5149",
1175-
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, config.outline, config.shadow, 8,
1176-
0, 0, 0, 1
1177-
);
1178-
1178+
"R2L", config.fontname, config.fontsize, primaryColour, "&H00FFFFFF", outlineColour, "&H1E6A5149",
1179+
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, config.outline, config.shadow, 8,
1180+
0, 0, 0, 1);
1181+
11791182
fprintf(fptr, "\nStyle: %s,%s,%d,%s,%s,%s,%s,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.1f,%.1f,%d,%d,%d,%d,%d",
1180-
"L2R", config.fontname, config.fontsize, primaryColour, "&H00FFFFFF", "&H00000000", "&H1E6A5149",
1181-
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, config.outline, config.shadow, 8,
1182-
0, 0, 0, 1
1183-
);
1184-
1183+
"L2R", config.fontname, config.fontsize, primaryColour, "&H00FFFFFF", outlineColour, "&H1E6A5149",
1184+
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, config.outline, config.shadow, 8,
1185+
0, 0, 0, 1);
1186+
11851187
fprintf(fptr, "\nStyle: %s,%s,%d,%s,%s,%s,%s,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.1f,%.1f,%d,%d,%d,%d,%d",
1186-
"TOP", config.fontname, config.fontsize, primaryColour, "&H00FFFFFF", "&H00000000", "&H1E6A5149",
1187-
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, config.outline, config.shadow, 8,
1188-
0, 0, 0, 1
1189-
);
1190-
1188+
"TOP", config.fontname, config.fontsize, primaryColour, "&H00FFFFFF", outlineColour, "&H1E6A5149",
1189+
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, config.outline, config.shadow, 8,
1190+
0, 0, 0, 1);
1191+
11911192
fprintf(fptr, "\nStyle: %s,%s,%d,%s,%s,%s,%s,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.1f,%.1f,%d,%d,%d,%d,%d",
1192-
"BTM", config.fontname, config.fontsize, primaryColour, "&H00FFFFFF", "&H00000000", "&H1E6A5149",
1193-
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, config.outline, config.shadow, 8,
1194-
0, 0, 0, 1
1195-
);
1196-
1193+
"BTM", config.fontname, config.fontsize, primaryColour, "&H00FFFFFF", outlineColour, "&H1E6A5149",
1194+
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, config.outline, config.shadow, 8,
1195+
0, 0, 0, 1);
1196+
11971197
fprintf(fptr, "\nStyle: %s,%s,%d,%s,%s,%s,%s,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.1f,%.1f,%d,%d,%d,%d,%d",
1198-
"SP", config.fontname, config.fontsize, "&H00FFFFFF", "&H00FFFFFF", "&H00000000", "&H1E6A5149",
1199-
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, config.outline, config.shadow, 7,
1200-
0, 0, 0, 1
1201-
);
1198+
"SP", config.fontname, config.fontsize, "&H00FFFFFF", "&H00FFFFFF", outlineColour, "&H1E6A5149",
1199+
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, config.outline, config.shadow, 7,
1200+
0, 0, 0, 1);
12021201
float msgboxOutline = config.outline * config.msgboxFontsize / config.fontsize;
12031202
float msgboxShadow = config.shadow * config.msgboxFontsize / config.fontsize;
12041203
fprintf(fptr, "\nStyle: %s,%s,%d,%s,%s,%s,%s,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.1f,%.1f,%d,%d,%d,%d,%d",
1205-
"MSG", config.fontname, config.msgboxFontsize, "&H00FFFFFF", "&H00FFFFFF", "&H00000000", "&H1E6A5149",
1206-
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, msgboxOutline, msgboxShadow, 7,
1207-
0, 0, 0, 1
1208-
);
1209-
1204+
"MSG", config.fontname, config.msgboxFontsize, "&H00FFFFFF", "&H00FFFFFF", outlineColour, "&H1E6A5149",
1205+
bold, 0, 0, 0, 100.00, 100.00, 0.00, 0.00, 1, msgboxOutline, msgboxShadow, 7,
1206+
0, 0, 0, 1);
1207+
12101208
if (config.statmode != 0)
12111209
{
12121210
fprintf(fptr, "\nStyle: %s,%s,%d,%s,%s,%s,%s,%d,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%d,%.1f,%.1f,%d,%d,%d,%d,%d",

Config/Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct Configurations
5858
int opacity; /* 不透明度 */
5959
float outline; /* 描边 */
6060
float outlineBlur; /* 描边模糊半径 */
61+
int outlineOpacity; /* 描边不透明度 */
6162
float shadow; /* 阴影 */
6263
BOOL bold; /* 是否加粗 */
6364

docs/DanmakuFactory CLI 参数说明.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
| -O, --opacity | 指定不透明度,越小越透明 | 1-255 的整数 | 180 | -O 255 |
2121
| -L, --outline | 指定描边成都 | 0-4 整数 | 0 | -L 4 |
2222
| --outline-blur | 指定描边模糊半径 | 非负浮点数 | 0 | --outline-blur 1 |
23+
| --outline-opacity | 指定描边不透明度(单位:0-255)<br />默认值为 255,表示完全不透明<br /> | 0-255 整数 | 255 | --outline-opacity 128 |
2324
| -D, --shadow | 指定阴影深度 | 0-4 整数 | 1 | -D 4 |
2425
| -B, --bold | 指定是否使用粗体字 | true / false | false | -B true |
2526
| --displayarea | 全部弹幕的显示范围 | 0.0-1.0 浮点数 | 1.00 | --displayarea 0.5 |

main.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static CONFIG defaultConfig =
6666
180, /* 不透明度 */
6767
0, /* 描边 */
6868
0, /* 描边模糊半径 */
69+
255, /* 描边不透明度 */
6970
1, /* 阴影 */
7071
FALSE, /* 是否加粗 */
7172

@@ -431,8 +432,19 @@ int main(int argc, char **argv)
431432
return 0;
432433
}
433434
config.outlineBlur = returnValue;
434-
435-
argCnt += 2;
435+
436+
argCnt += 2;
437+
}
438+
else if (!strcmp("--outline-opacity", argv[argCnt]))
439+
{ /* 描边不透明度 */
440+
double returnValue = getArgValDouble(argc, argv, argCnt, "OutlineOpacity", -256.00);
441+
if (fabs(returnValue - (-256.0)) < EPS)
442+
{
443+
return 0;
444+
}
445+
config.outlineOpacity = (int)returnValue;
446+
447+
argCnt += 2;
436448
}
437449
else if (!strcmp("-D", argv[argCnt]) || !strcmp("--shadow", argv[argCnt]))
438450
{ /* 阴影 */
@@ -886,6 +898,13 @@ int main(int argc, char **argv)
886898
"\n\"OutlineBlur\" is ignored since \"Outline\" is set to 0.\n");
887899
toPause(ignoreWarnings);
888900
}
901+
/* 描边不透明度 */
902+
if (config.outlineOpacity < 0 || config.outlineOpacity > 255)
903+
{
904+
fprintf(stderr, "\nERROR"
905+
"\n\"OutlineOpacity\" must be an integer greater than or equal to 0 and less than or equal to 255.\n");
906+
return 0;
907+
}
889908
/* 阴影 */
890909
if (config.shadow < 0.0|| config.shadow > 4.0)
891910
{
@@ -1448,6 +1467,8 @@ void printHelpInfo()
14481467
"\n-L, --outline Specify the width of outline for each danmaku(range: 0-4)."
14491468
"\n--outline-blur Specify the blur radius of outline for each danmaku."
14501469
"\n Available value: 0 (default) or positive number"
1470+
"\n--outline-opacity Specify the opacity of outline for danmaku EXCEPT the special danmaku"
1471+
"\n Available value: 0-255 (default: 255)"
14511472
"\n-D, --shadow Specify the depth of shadow for each danmaku(range: 0-4)."
14521473
"\n-B, --bold Specify whether the font should be boldface."
14531474
"\n Available value: TRUE, FALSE (default)"

0 commit comments

Comments
 (0)