Skip to content

Commit 0150dd6

Browse files
committed
Refined dist
1 parent 80e91d5 commit 0150dd6

7 files changed

Lines changed: 182 additions & 6 deletions

File tree

build/CommentCoreLibrary.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,14 @@ var CommentManager = (function() {
797797
}
798798

799799
/** Public **/
800+
CommentManager.prototype.stop = function(){
801+
this.stopTimer();
802+
};
803+
804+
CommentManager.prototype.start = function(){
805+
this.startTimer();
806+
};
807+
800808
CommentManager.prototype.seek = function(time){
801809
this.position = this.timeline.bsearch(time,function(a,b){
802810
if(a < b.stime) return -1
@@ -830,6 +838,24 @@ var CommentManager = (function() {
830838
this.dispatchEvent("load");
831839
};
832840

841+
CommentManager.prototype.insert = function(c){
842+
this.timeline.binsert(c,function(a,b){
843+
if(a.stime > b.stime) return 2;
844+
else if(a.stime < b.stime) return -2;
845+
else{
846+
if(a.date > b.date) return 1;
847+
else if(a.date < b.date) return -1;
848+
else if(a.dbid != null && b.dbid != null){
849+
if(a.dbid > b.dbid) return 1;
850+
else if(a.dbid < b.dbid) return -1;
851+
return 0;
852+
}else
853+
return 0;
854+
}
855+
});
856+
this.dispatchEvent("insert");
857+
};
858+
833859
CommentManager.prototype.clear = function(){
834860
while(this.runline.length > 0){
835861
this.runline[0].finish();

build/CommentCoreLibrary.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/scripting/sandbox.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ window.addEventListener('load',function(){
2222
});
2323
$("evaluate-host").addEventListener("click", function(){
2424
var sandbox = window.sandbox;
25-
eval($("console-input").value);
25+
try{
26+
eval($("console-input").value);
27+
}catch(e){
28+
bscripter.logger.error("[Host] " + e.stack.toString());
29+
};
2630
});
2731
function fetchFile(filename){
2832
var xhr = new XMLHttpRequest();

docs/CommentCoreLibraryAPI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
CCL API (程序接口)
2-
====
1+
# CCL API (程序接口)
2+
33
Note, the API spec is not completely and correctly implemented yet. 注意,目前尚未
44
完全实现这些接口。
55

docs/CommentObject.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# 弹幕抽象对象 IComment
2+
3+
`v1.0` 后,CommentCoreLibrary采用抽象化弹幕对象。这样便于实现不同的渲染幕布的支持,和复杂的
4+
运动轨迹支持。在新的模式下,一个单独的弹幕管理器将可以比较容易的支持渲染到 DOM, Canvas 和 WebGL
5+
等平面,而且支持新种类的弹幕将会非常容易。
6+
7+
新的变化也允许了我们抽象化空间规划模块,这样实现新的空间规划或者更改空间规划模块的模式将会变得容易到
8+
仅需扩展数行的规划规则。同时这样也大量的削减了代码重复,提高了效率。
9+
10+
下面我们将介绍抽象化弹幕对象:
11+
12+
## Properties 属性
13+
14+
### LINEAR <Func> [静态]
15+
LINEAR 为线形拟合函数,提供用于默认补间动画的拟合。
16+
17+
### mode <Num>
18+
Danmaku Mode: mode 表示弹幕的类型,参考 [弹幕类型 (Comment Types)](CommentTypes.md)
19+
20+
### stime <Num> = 0
21+
Start Time: stime 表示弹幕相对于视频位置的开始时间(ms),`0`即在视频开始立即出现
22+
23+
### text <String>
24+
Text: text 表示弹幕的文字内容。注意:在创造弹幕对象后,对 text 的更改将无意义。
25+
26+
### ttl <Num>
27+
Time To Live: ttl 表示弹幕剩余的生存时间(ms)(注意:在css模式下该子段可能不准确)
28+
29+
### dur <Num> = 4000
30+
Duration: dur 表示弹幕的总生存时间(ms)。默认情况下,对于滚动弹幕这个数字是 4000。
31+
32+
### cindex <Num> = -1
33+
Pool Index: cindex 表示弹幕的弹幕池ID,用于在删除弹幕时寻找弹幕所在弹幕池。
34+
35+
### motion <Array<IMotion>> = []
36+
Motion Group: motion 控制一般弹幕(CoreComment)的运动轨迹,别的类型的弹幕可能忽略此属性(如
37+
滚动弹幕)
38+
39+
### movable <Bool> = true
40+
Is Movable: 弹幕是否可以移动。此处为 `False` 时,弹幕的 time 函数将不会调用 update() 来移动
41+
弹幕。这样弹幕将无动画效果(不管 motion 或者 update 函数的实现)。但是更改 `x,y` 坐标还是可以
42+
重新定位弹幕的。
43+
44+
### align <Num> = 0
45+
Alignment: 对齐锚点(方形四角)。此数的高位表示上下,低位表示左右。
46+
47+
Byte | Number | Alignment
48+
-----------------------------------------
49+
0 0 | 0 | Top Left (Default)
50+
-----------------------------------------
51+
0 1 | 1 | Top Right
52+
-----------------------------------------
53+
1 0 | 2 | Bottom Left
54+
-----------------------------------------
55+
1 1 | 3 | Bottom Right
56+
57+
设定后x,y坐标的锚点将变成对应的方形角。不过,在右和下的对齐时,读取 x,y 坐标不一定准确,而且因为
58+
效率低所以不推荐。比如 top right 模式下,读 x 坐标效率比较低,但是读 y 就要好很多。
59+
60+
### absolute <Bool> = true
61+
Absolute Coordinates: 是否使用绝对坐标。当 `absolute === false` 时,x,y坐标将会表示相对
62+
于整个弹幕管理器的比例,如 `x=0.5``640 x 480` 的管理器上则会显示在 `320` 位置。
63+
64+
注意:width, height 总会以绝对坐标返回,所以如果需要叠加则必须手动转换到相对坐标。
65+
66+
### width/height/bottom/right <Num>
67+
Bounding Box: 定义弹幕的宽高和下部右部位置,前两个定义了 top left 顶点,后两个定义了bottom
68+
right顶点。
69+
70+
### size <Num> = 25
71+
Font Size: 弹幕的文字大小,请参考 [弹幕大小 Comment Sizes](CommentSizes.md)。更改会更新视图。
72+
73+
### color <Num> = 0xffffff
74+
Text Color: 文字颜色,为数字表示,RGB依次由高位到低位:`0xRRGGBB`。更改会更新视图。
75+
76+
### border <Bool> = false
77+
Display Border: 是否显示边框。用于标注新弹幕。更改会同步更新视图。
78+
79+
### shadow <Bool> = true
80+
Display Shadow: 是否显示弹幕描边/阴影(注意:具体用哪个描边效果需要CSS控制)。更改会同步更新视图。
81+
82+
### font <String> = ""
83+
Font Family: 弹幕字体。当设置为空字符串时,使用默认字体。更改会同步更新视图。
84+
85+
### parent <CommentManager>
86+
Parent: 此弹幕归属的上层管理器
87+
88+
### dom <HTMLDivElement/Canvas/etc.>
89+
DOM Correspondance: 对应的渲染元素,根据不同情况是不一样的。默认是 DIV 元素。
90+
91+
## Methods 方法
92+
93+
### constructor(cm:CommentManager, data:Object)
94+
构造函数,需要提供作为 parent 的 CommentManager 和用于填补属性的初始 data 对象。
95+
96+
### init(recycle:IComment = null)
97+
初始化弹幕。在dom版本里面,`.dom` 对象只有在 init 后才会被创建。在 `init()` 之前也不可读取 x,y
98+
等坐标信息(因为未初始化)。可以给一个旧的 IComment 让新的 IComment接管原来的 Comment 的 dom
99+
对象(而不是构造新的)。当然,不提供此参数,则会创建新的渲染构件。
100+
101+
### time(dt:Number)
102+
前进 dt 毫秒(ms)。当 dt 是负数时不保证支持。此函数会根据情况更新界面。CSS控制的弹幕也需要调用,
103+
用于进行打扫。
104+
105+
### update()
106+
根据 ttl 和 dur 计算弹幕位置,并渲染
107+
108+
### invalidate()
109+
无效化缓存的弹幕空间信息。下次读取 width, height, x, y, right, bottom 强制重新计算。
110+
111+
### animate()
112+
根据 motion 对象对弹幕进行补间动画。
113+
114+
### finish()
115+
通知 parent 弹幕已经完结。
116+
117+
### toString():String
118+
返回弹幕调试信息。
119+
120+

src/CommentCoreLibrary.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ var CommentManager = (function() {
6868
}
6969

7070
/** Public **/
71+
CommentManager.prototype.stop = function(){
72+
this.stopTimer();
73+
};
74+
75+
CommentManager.prototype.start = function(){
76+
this.startTimer();
77+
};
78+
7179
CommentManager.prototype.seek = function(time){
7280
this.position = this.timeline.bsearch(time,function(a,b){
7381
if(a < b.stime) return -1
@@ -101,6 +109,24 @@ var CommentManager = (function() {
101109
this.dispatchEvent("load");
102110
};
103111

112+
CommentManager.prototype.insert = function(c){
113+
this.timeline.binsert(c,function(a,b){
114+
if(a.stime > b.stime) return 2;
115+
else if(a.stime < b.stime) return -2;
116+
else{
117+
if(a.date > b.date) return 1;
118+
else if(a.date < b.date) return -1;
119+
else if(a.dbid != null && b.dbid != null){
120+
if(a.dbid > b.dbid) return 1;
121+
else if(a.dbid < b.dbid) return -1;
122+
return 0;
123+
}else
124+
return 0;
125+
}
126+
});
127+
this.dispatchEvent("insert");
128+
};
129+
104130
CommentManager.prototype.clear = function(){
105131
while(this.runline.length > 0){
106132
this.runline[0].finish();

tests/scripting/3dsphere.biliscript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ var screen = $.createShape({
3232
lifeTime: 1000
3333
});
3434
screen.transform.matrix3D = null;
35-
screen.x = 640 / 2;
36-
screen.y = 400 / 2;
35+
screen.x = $.width / 2;
36+
screen.y = $.height / 2;
3737

3838
function getR(a, c) {
3939
return Math.sqrt(c * c - a * a);

0 commit comments

Comments
 (0)