@xpadev-net/niconicomments 0.1.9 → 0.1.12
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/dist/bundle.js +30 -20
- package/package.json +2 -1
package/dist/bundle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
niconicomments.js v0.1.
|
|
3
|
-
(c) 2021 xpadev-net https://
|
|
2
|
+
niconicomments.js v0.1.12
|
|
3
|
+
(c) 2021 xpadev-net https://xpadev.net
|
|
4
4
|
Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
@@ -24,29 +24,30 @@
|
|
|
24
24
|
this.canvas = canvas;
|
|
25
25
|
this.context = canvas.getContext("2d");
|
|
26
26
|
this.context.strokeStyle = "rgba(0,0,0,0.7)";
|
|
27
|
-
this.context.textAlign = "
|
|
28
|
-
this.context.textBaseline = "
|
|
27
|
+
this.context.textAlign = "start";
|
|
28
|
+
this.context.textBaseline = "alphabetic";
|
|
29
29
|
this.context.lineWidth = 4;
|
|
30
30
|
|
|
31
31
|
if (options.useLegacy) {
|
|
32
|
-
this.commentYOffset = 0.
|
|
32
|
+
this.commentYOffset = 0.0;
|
|
33
33
|
} else {
|
|
34
|
-
this.commentYOffset = 0.
|
|
34
|
+
this.commentYOffset = 0.0;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
this.
|
|
37
|
+
this.commentYPaddingTop = 0.08;
|
|
38
|
+
this.commentYMarginBottom = 0.24;
|
|
38
39
|
this.fontSize = {
|
|
39
40
|
"small": {
|
|
40
41
|
"default": 47,
|
|
41
|
-
"resized":
|
|
42
|
+
"resized": 26.1
|
|
42
43
|
},
|
|
43
44
|
"medium": {
|
|
44
|
-
"default":
|
|
45
|
-
"resized":
|
|
45
|
+
"default": 74,
|
|
46
|
+
"resized": 38.7
|
|
46
47
|
},
|
|
47
48
|
"big": {
|
|
48
|
-
"default":
|
|
49
|
-
"resized":
|
|
49
|
+
"default": 111,
|
|
50
|
+
"resized": 61
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
this.defaultCommandValue = {
|
|
@@ -90,6 +91,7 @@
|
|
|
90
91
|
this.collision_left = {};
|
|
91
92
|
this.collision_ue = {};
|
|
92
93
|
this.collision_shita = {};
|
|
94
|
+
this.lastVpos = null;
|
|
93
95
|
this.useLegacy = options.useLegacy;
|
|
94
96
|
this.preRendering();
|
|
95
97
|
this.fpsCount = 0;
|
|
@@ -176,7 +178,7 @@
|
|
|
176
178
|
this.data[i]._live = command._live;
|
|
177
179
|
this.data[i].long = command.long;
|
|
178
180
|
this.data[i].invisible = command.invisible;
|
|
179
|
-
this.data[i].content = this.data[i].content.replaceAll("\t", "
|
|
181
|
+
this.data[i].content = this.data[i].content.replaceAll("\t", " ");
|
|
180
182
|
}
|
|
181
183
|
}
|
|
182
184
|
/**
|
|
@@ -469,10 +471,10 @@
|
|
|
469
471
|
width = width_arr.reduce((p, c) => p + c, 0) / width_arr.length;
|
|
470
472
|
width_max = Math.max(...width_arr);
|
|
471
473
|
width_min = Math.min(...width_arr);
|
|
472
|
-
height =
|
|
474
|
+
height = comment.fontSize * (1 + this.commentYPaddingTop) * lines.length + this.commentYMarginBottom * comment.fontSize;
|
|
473
475
|
|
|
474
476
|
if (comment.loc !== "naka" && !comment.tateRisized) {
|
|
475
|
-
if (comment.full && width_max >
|
|
477
|
+
if (comment.full && width_max > 1840) {
|
|
476
478
|
comment.fontSize -= 1;
|
|
477
479
|
comment.resized = true;
|
|
478
480
|
comment.yokoResized = true;
|
|
@@ -566,9 +568,9 @@
|
|
|
566
568
|
posY;
|
|
567
569
|
|
|
568
570
|
if (comment.loc === "shita") {
|
|
569
|
-
posY = 1080 - comment.posY
|
|
571
|
+
posY = 1080 - comment.posY - comment.height + (Number(i) + 1) * comment.fontSize * (1 + this.commentYPaddingTop);
|
|
570
572
|
} else {
|
|
571
|
-
posY = comment.posY + i
|
|
573
|
+
posY = comment.posY + (Number(i) + 1) * comment.fontSize * (1 + this.commentYPaddingTop);
|
|
572
574
|
}
|
|
573
575
|
|
|
574
576
|
this.context.strokeText(line, posX, posY);
|
|
@@ -576,7 +578,7 @@
|
|
|
576
578
|
|
|
577
579
|
if (this.showCollision) {
|
|
578
580
|
this.context.strokeStyle = "rgba(255,255,0,0.5)";
|
|
579
|
-
this.context.strokeRect(posX, posY, comment.width_max, comment.fontSize);
|
|
581
|
+
this.context.strokeRect(posX, posY, comment.width_max, comment.fontSize * -1);
|
|
580
582
|
|
|
581
583
|
if (comment.color === "#000000") {
|
|
582
584
|
this.context.strokeStyle = "rgba(255,255,255,0.7)";
|
|
@@ -886,6 +888,8 @@
|
|
|
886
888
|
|
|
887
889
|
|
|
888
890
|
drawCanvas(vpos) {
|
|
891
|
+
if (this.lastVpos === vpos) return;
|
|
892
|
+
this.lastVpos = vpos;
|
|
889
893
|
this.fpsCount++;
|
|
890
894
|
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
891
895
|
|
|
@@ -946,8 +950,14 @@
|
|
|
946
950
|
if (this.showCommentCount) {
|
|
947
951
|
this.context.font = parseFont("defont", 60, this.useLegacy);
|
|
948
952
|
this.context.fillStyle = "#00FF00";
|
|
949
|
-
|
|
950
|
-
|
|
953
|
+
|
|
954
|
+
if (this.timeline[vpos]) {
|
|
955
|
+
this.context.strokeText("Count:" + this.timeline[vpos].length, 100, 200);
|
|
956
|
+
this.context.fillText("Count:" + this.timeline[vpos].length, 100, 200);
|
|
957
|
+
} else {
|
|
958
|
+
this.context.strokeText("Count:0", 100, 200);
|
|
959
|
+
this.context.fillText("Count:0", 100, 200);
|
|
960
|
+
}
|
|
951
961
|
}
|
|
952
962
|
}
|
|
953
963
|
/**
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpadev-net/niconicomments",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "NiconiComments is a comment drawing library that is somewhat compatible with the official Nico Nico Douga player.",
|
|
5
5
|
"main": "dist/bundle.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"build": "rollup -c rollup.config.js",
|
|
9
|
+
"watch": "rollup -c rollup.config.js -w",
|
|
9
10
|
"prepublishOnly": "rollup -c rollup.config.js"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|