diff --git a/docs/index.html b/docs/index.html index 6449c010..6094d7d9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -34,6 +34,7 @@
trueの場合はCAを投稿していると推定されるユーザーのレイヤーを分けて位置決定をおこないます
+また、該当CAの拡大縮小を抑制する効果もあります
"flash"の場合は、Saccubus/ZenzaWatchなどflash時代の互換プレイヤーに近い動作をします
表示コメントサイズを拡大縮小します
+keepCAを併用することを推奨します
+初期化後も随時設定の変更が可能です
diff --git a/src/@types/types.d.ts b/src/@types/types.d.ts index 0b2d523f..71cb9fe3 100644 --- a/src/@types/types.d.ts +++ b/src/@types/types.d.ts @@ -8,34 +8,36 @@ type inputFormatType = | "default"; type modeType = "default" | "html5" | "flash"; type InitOptions = { - mode?: modeType; - useLegacy?: boolean; - formatted?: boolean; - format?: inputFormatType; - video?: HTMLVideoElement | undefined; - showCollision?: boolean; - showFPS?: boolean; - showCommentCount?: boolean; - drawAllImageOnLoad?: boolean; + config?: ConfigNullable; debug?: boolean; + drawAllImageOnLoad?: boolean; enableLegacyPiP?: boolean; + format?: inputFormatType; + formatted?: boolean; keepCA?: boolean; - config?: ConfigNullable; + mode?: modeType; + scale?: number; + showCollision?: boolean; + showCommentCount?: boolean; + showFPS?: boolean; + useLegacy?: boolean; + video?: HTMLVideoElement | undefined; }; type Options = { - mode: modeType; - useLegacy: boolean; - formatted: boolean; - format: inputFormatType; - video: HTMLVideoElement | undefined; - showCollision: boolean; - showFPS: boolean; - showCommentCount: boolean; - drawAllImageOnLoad: boolean; + config: ConfigNullable; debug: boolean; + drawAllImageOnLoad: boolean; enableLegacyPiP: boolean; + format: inputFormatType; + formatted: boolean; keepCA: boolean; - config: ConfigNullable; + mode: modeType; + scale: number; + showCollision: boolean; + showCommentCount: boolean; + showFPS: boolean; + useLegacy: boolean; + video: HTMLVideoElement | undefined; }; type rawApiResponse = { [key: string]: apiPing | apiThread | apiLeaf | apiGlobalNumRes | apiChat; diff --git a/src/definition/config.ts b/src/definition/config.ts index ec054181..87b6c718 100644 --- a/src/definition/config.ts +++ b/src/definition/config.ts @@ -160,19 +160,20 @@ const defaultConfig: Config = { * 既定の設定 */ const defaultOptions: Options = { - mode: "default", + config: {}, + debug: false, drawAllImageOnLoad: false, + enableLegacyPiP: false, format: "default", formatted: false, - debug: false, - enableLegacyPiP: false, keepCA: false, + mode: "default", + scale: 1, showCollision: false, showCommentCount: false, showFPS: false, useLegacy: false, video: undefined, - config: {}, }; let config: Config; diff --git a/src/main.ts b/src/main.ts index cb3bd8bd..dc500b90 100644 --- a/src/main.ts +++ b/src/main.ts @@ -35,7 +35,6 @@ class NiconiComments { private readonly canvas: HTMLCanvasElement; private readonly collision: collision; private readonly context: CanvasRenderingContext2D; - private readonly keepCA: boolean; private readonly nicoScripts: nicoScript; private readonly timeline: { [key: number]: number[] }; private readonly mode: modeType; @@ -104,8 +103,6 @@ class NiconiComments { this.showFPS = options.showFPS; this.showCommentCount = options.showCommentCount; this.enableLegacyPiP = options.enableLegacyPiP; - this.keepCA = options.keepCA; - console.log(this.keepCA); this.cacheIndex = {}; this.timeline = {}; @@ -137,7 +134,7 @@ class NiconiComments { */ preRendering(rawData: formattedComment[], drawAll: boolean) { const preRenderingStart = performance.now(); - if (this.keepCA) { + if (options.keepCA) { rawData = changeCALayer(rawData); } const parsedData: parsedComment[] = this.getCommentPos( @@ -185,13 +182,21 @@ class NiconiComments { } const measure = this.measureText(comment); const size = parsedData[comment.index] as formattedCommentWithSize; + if (options.scale !== 1 && size.layer === -1) { + measure.height *= options.scale; + measure.width *= options.scale; + measure.width_max *= options.scale; + measure.width_min *= options.scale; + //measure.lineHeight *= options.scale; + measure.fontSize *= options.scale; + } size.height = measure.height; size.width = measure.width; size.width_max = measure.width_max; size.width_min = measure.width_min; size.lineHeight = measure.lineHeight; + size.fontSize = measure.fontSize; if (measure.resized) { - size.fontSize = measure.fontSize; this.context.font = parseFont(font, fontSize, this.mode); } result[comment.index] = size; diff --git a/src/typeGuard.ts b/src/typeGuard.ts index a736eaf6..f1d3851f 100644 --- a/src/typeGuard.ts +++ b/src/typeGuard.ts @@ -224,6 +224,7 @@ const typeGuard = { debug: isBoolean, enableLegacyPiP: isBoolean, keepCA: isBoolean, + scale: isNumber, config: typeGuard.config.config, format: (i: unknown) => typeof i === "string" && @@ -234,7 +235,6 @@ const typeGuard = { typeof i === "object" && (i as HTMLVideoElement).nodeName === "VIDEO", }; for (const key in keys) { - console.log(keys[key]); if ( (item as { [key: string]: unknown })[key] !== undefined && !(keys[key] as (i: unknown) => boolean)( @@ -333,7 +333,6 @@ const typeGuard = { ) === 0, }; for (const key in item) { - console.log(key, item, keys); if ( (item as { [key: string]: unknown })[key] !== undefined && !(keys[key] as (i: unknown) => boolean)(