koishi-plugin-cchess 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -4
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -63,6 +63,7 @@ exports.Config = koishi_1.Schema.object({
|
|
|
63
63
|
defaultEngineThinkingDepth: koishi_1.Schema.number().min(0).max(100).default(10).description(`默认引擎思考深度,越高 AI 棋力越强。由于 Nodejs 不支持 SIMD,所以不建议设置过高。`),
|
|
64
64
|
defaultMaxLeaderboardEntries: koishi_1.Schema.number().min(0).default(10).description(`显示排行榜时默认的最大人数。`),
|
|
65
65
|
retractDelay: koishi_1.Schema.number().min(0).default(0).description(`自动撤回等待的时间,单位是秒。值为 0 时不启用自动撤回功能。`),
|
|
66
|
+
imgScale: koishi_1.Schema.number().min(1).default(1).description(`图片分辨率倍率。`),
|
|
66
67
|
imageType: koishi_1.Schema.union(['png', 'jpeg', 'webp']).default('png').description(`发送的图片类型。`),
|
|
67
68
|
isTextToImageConversionEnabled: koishi_1.Schema.boolean().default(false).description(`是否开启将文本转为图片的功能(可选),如需启用,需要启用 \`markdownToImage\` 服务。`),
|
|
68
69
|
isChessImageWithOutlineEnabled: koishi_1.Schema.boolean().default(true).description(`是否为象棋图片添加辅助外框,关闭后可以显著提升图片速度,但无辅助外框,玩起来可能会比较累。`),
|
|
@@ -92,7 +93,7 @@ function apply(ctx, config) {
|
|
|
92
93
|
const ke = 120;
|
|
93
94
|
const weight = 500;
|
|
94
95
|
const height = 550;
|
|
95
|
-
const scale =
|
|
96
|
+
const scale = config.imgScale;
|
|
96
97
|
const isFlipBoard = false;
|
|
97
98
|
const engineSettings = {
|
|
98
99
|
Threads: 1,
|
|
@@ -1569,12 +1570,12 @@ function apply(ctx, config) {
|
|
|
1569
1570
|
}
|
|
1570
1571
|
}
|
|
1571
1572
|
async function createImage(buffer) {
|
|
1572
|
-
const canvas = await ctx.canvas.createCanvas(
|
|
1573
|
+
const canvas = await ctx.canvas.createCanvas(620 * scale, 780 * scale);
|
|
1573
1574
|
const context = canvas.getContext('2d');
|
|
1574
1575
|
const outerFrame = await ctx.canvas.loadImage(outerFrameImg);
|
|
1575
|
-
context.drawImage(outerFrame, 0, 0,
|
|
1576
|
+
context.drawImage(outerFrame, 0, 0, 620 * scale, 780 * scale);
|
|
1576
1577
|
const boardImg = await ctx.canvas.loadImage(buffer);
|
|
1577
|
-
context.drawImage(boardImg,
|
|
1578
|
+
context.drawImage(boardImg, 36.5 * scale, 90 * scale, 550 * scale, 605 * scale);
|
|
1578
1579
|
return canvas.toBuffer('image/png');
|
|
1579
1580
|
}
|
|
1580
1581
|
function isMoveString(str) {
|
package/package.json
CHANGED