Skip to content

Commit

Permalink
fix: x position of comment
Browse files Browse the repository at this point in the history
  • Loading branch information
xpadev-net committed Nov 17, 2022
1 parent 5aef011 commit c285b93
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/@types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ type Config = {
canvasWidth: number;
collisionRange: { [key in "left" | "right"]: number };
colors: { [key: string]: string };
commentDrawPadding: configItem<number>;
commentDrawRange: configItem<number>;
commentDrawPadding: number;
commentDrawRange: number;
commentScale: configItem<number>;
commentStageSize: configItem<commentStageSize>;
commentYMarginBottom: configSizeItem<number>;
Expand Down
6 changes: 2 additions & 4 deletions src/comments/FlashComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,15 +608,13 @@ class FlashComment implements IComment {
getPosX(
this.comment.width,
vpos - this.comment.vpos,
this.comment.long,
true
this.comment.long
);
} else {
posX = getPosX(
this.comment.width,
vpos - this.comment.vpos,
this.comment.long,
true
this.comment.long
);
}
if (posX > config.canvasWidth || posX + this.comment.width < 0) {
Expand Down
6 changes: 2 additions & 4 deletions src/comments/HTML5Comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,13 @@ class HTML5Comment implements IComment {
getPosX(
this.comment.width,
vpos - this.comment.vpos,
this.comment.long,
this.comment.flash
this.comment.long
);
} else {
posX = getPosX(
this.comment.width,
vpos - this.comment.vpos,
this.comment.long,
this.comment.flash
this.comment.long
);
}
if (posX > config.canvasWidth || posX + this.comment.width < 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/definition/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ const initConfig = () => {
/**
* コメントの処理範囲
*/
commentDrawRange: 1450,
commentDrawRange: 1530,
/**
* コメントの処理範囲外(片側)の幅
* (config.canvasWidth - config.commentDrawRange) / 2,
*/
commentDrawPadding: 235,
commentDrawPadding: 195,
/**
* 当たり判定の左右幅
* left: collisionWidth,
Expand Down
14 changes: 2 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,7 @@ class NiconiComments {
count++;
for (let j = beforeVpos; j < comment.long + 125; j++) {
const vpos = comment.vpos + j;
const left_pos = getPosX(
comment.width,
j,
comment.long,
comment.flash
);
const left_pos = getPosX(comment.width, j, comment.long);
if (
left_pos + comment.width >= config.collisionRange.right &&
left_pos <= config.collisionRange.right
Expand Down Expand Up @@ -205,12 +200,7 @@ class NiconiComments {
}
for (let j = beforeVpos; j < comment.long + 125; j++) {
const vpos = comment.vpos + j;
const left_pos = getPosX(
comment.width,
j,
comment.long,
comment.flash
);
const left_pos = getPosX(comment.width, j, comment.long);
arrayPush(this.timeline, vpos, index);
if (
left_pos + comment.width >= config.collisionRange.right &&
Expand Down
17 changes: 3 additions & 14 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,11 @@ const getPosY = (
* @param {number} width
* @param {number} vpos
* @param {number} long
* @param {boolean} isFlash
*/
const getPosX = (
width: number,
vpos: number,
long: number,
isFlash: boolean
): number => {
const getPosX = (width: number, vpos: number, long: number): number => {
const speed = (config.commentDrawRange + width) / (long + 100);
return (
getConfig(config.commentDrawRange, isFlash) -
((((width + getConfig(config.commentDrawRange, isFlash)) *
((vpos + 100) / 100)) /
4) *
300) /
long +
getConfig(config.commentDrawPadding, isFlash)
config.commentDrawPadding + config.commentDrawRange - (vpos + 100) * speed
);
};
/**
Expand Down

0 comments on commit c285b93

Please sign in to comment.