Skip to content

Commit e09078b

Browse files
committed
Supports filters now\!\!
1 parent 441629d commit e09078b

File tree

11 files changed

+12811
-76
lines changed

11 files changed

+12811
-76
lines changed

demo/debugger.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,13 @@ function bindTests(){
409409
state.mode = 'video';
410410
loadDM(tests['test-6']);
411411
});
412+
$("load-cmt-file").addEventListener("click", function(e){
413+
var x = prompt("Please give comment file URL");
414+
if(!x){
415+
return;
416+
}
417+
loadDM(x);
418+
});
412419
}
413420

414421
function bindResize(){

demo/default.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ body{
66
background-color:#111;
77
}
88

9-
h2{
9+
h1, h2, h3{
1010
padding:0;
1111
margin:0 0 5px 0;
1212
}
@@ -73,6 +73,7 @@ a:hover{
7373
width:20%;
7474
padding:10px;
7575
overflow:hidden;
76+
min-width:270px;
7677
}
7778

7879
.sidebar a.button{

demo/index.htm

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,41 @@
3535
<div class="sidebar">
3636
<h2>Tests</h2>
3737
<div>
38-
<a id="test-1" class="button">Run Test 1</a>
39-
<a id="test-2" class="button">Run Test 2</a>
40-
<a id="test-3" class="button">Run Test 3</a>
41-
<a id="test-4" class="button">Run Test 4</a>
42-
<a id="test-5" class="button">Run Test 5</a>
43-
<a id="test-6" class="button">Run Test 6</a>
38+
<a id="test-1" class="button" href="javascript:;">Run Test 1</a>
39+
<a id="test-2" class="button" href="javascript:;">Run Test 2</a>
40+
<a id="test-3" class="button" href="javascript:;">Run Test 3</a>
41+
<a id="test-4" class="button" href="javascript:;">Run Test 4</a>
42+
<a id="test-5" class="button" href="javascript:;">Run Test 5</a>
43+
<a id="test-6" class="button" href="javascript:;">Run Test 6</a>
4444
<div style="clear:both;"></div>
4545
</div>
4646
<h2>Extended</h2>
4747
<div>
48-
<a id="test-7" class="button">Run Test 7 (WIP)</a>
49-
<a id="test-8" class="button">Run Test 8</a>
50-
<a id="test-9" class="button">Run Test 9</a>
51-
<a id="test-s" class="button">Run Test Scripting</a>
48+
<a id="test-7" class="button" href="javascript:;">Run Test 7 (WIP)</a>
49+
<a id="test-8" class="button" href="javascript:;">Run Test 8</a>
50+
<a id="test-9" class="button" href="javascript:;">Run Test 9</a>
51+
<a id="test-s" class="button" href="javascript:;">Run Test Scripting</a>
52+
<div style="clear:both;"></div>
53+
</div>
54+
<h3>AcFun (Experimental)</h3>
55+
<div>
56+
<a id="test-ac-1" class="button" href="javascript:;">Run Test 1</a>
57+
<a id="test-ac-2" class="button" href="javascript:;">Run Test 2</a>
58+
<div style="clear:both;"></div>
5259
</div>
53-
<p>AcFun (Experimental) <br>
54-
<a id="test-ac-1" class="button">Run Test 1</a>
55-
<a id="test-ac-2" class="button">Run Test 2</a> <br>
56-
</p>
5760
<p>Filters: <br>
5861
<a onclick="cm.filter.setRuntimeFilter(fefx.center_dim);" href="javascript:;">Apply Center-Transparency</a><br>
5962
<a onclick="cm.filter.setRuntimeFilter(fefx.center_speedup);" href="javascript:;">Apply Center-Speedup</a><br>
60-
<a id="profiler-start" href="#">Profiler</a><br>
63+
<a id="profiler-start" href="javascript:;">Profiler</a><br>
6164
<a onclick="cm.filter.setRuntimeFilter(null);" href="javascript:;">Clear Runtime Filters</a>
6265
</p>
6366
<p>APIs: <br>
64-
<a id="fs-all">Fullscreen</a> <br>
65-
<a id="fs-win">Windowed Fullscreen</a>
67+
<a id="fs-all" href="javascript:;">Fullscreen</a> <br>
68+
<a id="fs-win" href="javascript:;">Windowed Fullscreen</a>
6669
</p>
6770
<p>Links: <br>
68-
<a id="video-demo">Demo with video</a> <br>
71+
<a id="video-demo" href="javascript:;">Demo with video</a> <br>
72+
<a id="load-cmt-file" href="javascript:;">Load Custom URL</a> <br>
6973
<a href="../experimental/animation">CSS3 Transition Library</a> <br>
7074
<a href="transition-library-test.htm">CCL /w Transition Library (Alpha)</a>
7175
</p>

experimental/scripting/bscript.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,11 @@ CCLScripting = {
292292
"height":stage.offsetHeight,
293293
"style":{
294294
"position":"absolute",
295-
"top": (serialized.y ? serialized.y : 0) + "px",
296-
"left":(serialized.x ? serialized.x : 0) + "px"
295+
"top": /*(serialized.y ? serialized.y : 0) + */"0px",
296+
"left":/*(serialized.x ? serialized.x : 0) + */"0px"
297297
}});
298+
svg.y = (serialized.y ? serialized.y : 0);
299+
svg.x = (serialized.x ? serialized.x : 0);
298300
setTimeout(function(){
299301
stage.appendChild(svg.domParent);
300302
},1000);
@@ -457,8 +459,8 @@ CCLScripting = {
457459
};
458460
this.drawRect = function(params){
459461
var r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
460-
r.setAttribute("x", params[0]);
461-
r.setAttribute("y", params[1]);
462+
r.setAttribute("x", params[0] + this.x);
463+
r.setAttribute("y", params[1] + this.y);
462464
r.setAttribute("width", params[2]);
463465
r.setAttribute("height", params[3]);
464466
applyFill(r, this);
@@ -467,8 +469,8 @@ CCLScripting = {
467469
};
468470
this.drawRoundRect = function(params){
469471
var r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
470-
r.setAttribute("x", params[0]);
471-
r.setAttribute("y", params[1]);
472+
r.setAttribute("x", params[0] + this.x);
473+
r.setAttribute("y", params[1] + this.y);
472474
r.setAttribute("width", params[2]);
473475
r.setAttribute("height", params[3]);
474476
r.setAttribute("rx", params[4]);
@@ -479,8 +481,8 @@ CCLScripting = {
479481
};
480482
this.drawCircle = function(params){
481483
var c = document.createElementNS("http://www.w3.org/2000/svg", "circle");
482-
c.setAttribute("cx", params[0]);
483-
c.setAttribute("cy", params[1]);
484+
c.setAttribute("cx", params[0] + this.x);
485+
c.setAttribute("cy", params[1] + this.y);
484486
c.setAttribute("r", params[2]);
485487
applyFill(c, this);
486488
applyStroke(c, this);
@@ -489,8 +491,8 @@ CCLScripting = {
489491

490492
this.drawEllipse = function(params){
491493
var e = document.createElementNS("http://www.w3.org/2000/svg", "ellipse");
492-
e.setAttribute("cx", params[0]);
493-
e.setAttribute("cy", params[1]);
494+
e.setAttribute("cx", params[0] + this.x);
495+
e.setAttribute("cy", params[1] + this.y);
494496
e.setAttribute("rx", params[2]);
495497
e.setAttribute("ry", params[3]);
496498
applyFill(e, this);

experimental/scripting/greendam.biliscript

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
/*绿坝娘~和谐你*/
2-
/*Kanpai*/
3-
var x = $.createShape({lifeTime:10,x:0,y:0});
4-
x.graphics.beginFill(0xffffff);
5-
x.graphics.drawRect(0,0,540,383);
6-
x.graphics.endFill();
2+
var g = $.createShape({lifeTime:360,x:0,y:0});
3+
g.graphics.beginFill(0xffffff);
4+
g.graphics.drawRect(0,0,540,383);
5+
g.graphics.endFill();
76

7+
/*Background*/
8+
var h=$.createShape({x:0,y:0,alpha:0.2,lifeTime:300,motion:{
9+
alpha:{fromValue:0,toValue:0.5,lifeTime:1}}
10+
});
11+
h.graphics.beginFill(0x000000);
12+
h.graphics.drawRect(-5,-5,547,390);
13+
h.graphics.endFill();
14+
15+
16+
var g = $.createShape({x:-20,y:-20,lifeTime:300,motion:{
17+
alpha:{fromValue:0,toValue:0.99,lifeTime:1}}
18+
});
19+
g.graphics.beginFill(0xffffff);
20+
g.graphics.drawEllipse(10,16,560,380);
21+
g.graphics.endFill();
22+
g.filters=[$.createGlowFilter(0xFFFFFF,0.5,50,50,2,6,false,false),$.createBlurFilter(160,160)];
23+
24+
var g = $.createShape({lifeTime:360,x:0,y:0,alpha:0.2,motion:{
25+
alpha:{fromValue:0,toValue:0.2,lifeTime:1}}
26+
});
27+
g.graphics.beginFill(0x996600);
28+
g.graphics.drawRect(0,0,540,383);
29+
g.graphics.endFill()
30+
/*绿坝娘~和谐你*/
831
var s = $.createShape({lifeTime:7,motionGroup:[
932
{x:{fromValue:5,toValue:10,lifeTime:2},alpha:{fromValue:0,toValue:1,lifeTime:2}},
1033
{x:{fromValue:10,toValue:15,lifeTime:3}},

experimental/scripting/index.htm

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
.button{font-size:12px;z-index:99;}
1717
</style>
1818
<script type="text/javascript">var $ = function(e){return window.document.getElementById(e);}</script>
19-
<script src="bscript.js" type="text/javascript"></script>
19+
<script src="../../src/scripting/Host.js" type="text/javascript"></script>
2020
</head>
2121
<body style="background:#000;">
2222
<h2 style="color:#fff">CCL Scripting Demo</h2>
@@ -31,20 +31,11 @@ <h2 style="color:#fff">CCL Scripting Demo</h2>
3131
</div>
3232
<div id="output" style="color:#fff;">[Msg] 有关具体API信息请阅读 docs/scripting</div>
3333
<script type="text/javascript">
34-
bscripter = new CCLScripting.BridgedSandbox({}, $("player"));
35-
bscripter.addEventListener("trace", function(data){
36-
$("output").innerText = "[Trace] " + data + "\r\n" + $("output").innerText;
37-
});
38-
bscripter.addEventListener("cleanup", function(data){
39-
$("output").innerText = "[Cleanup] " + data + "\r\n" + $("output").innerText;
40-
});
34+
bscripter = new CCLScripting("../../src/scripting/Worker.js");
35+
sandbox = bscripter.getSandbox($("player"));
4136
$("evaluate").addEventListener("click", function(){
4237
try{
43-
var w = bscripter.eval($("code-input").value);
44-
w.onerror = function(error){
45-
$("output").innerText = error.message + "\r\n" + $("output").innerText;
46-
};
47-
console.log(w);
38+
sandbox.eval($("code-input").value);
4839
}catch(e){
4940
$("output").innerText = e.message + "\r\n" + $("output").innerText;
5041
}
@@ -69,7 +60,7 @@ <h2 style="color:#fff">CCL Scripting Demo</h2>
6960
fetchFile("greendam.biliscript");
7061
});
7162
$("debug-clear").addEventListener("click", function(){
72-
bscripter.clear();
63+
//bscripter.clear();
7364
});
7465
</script>
7566
</body>

experimental/scripting/madoka.biliscript

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
/*马猴烧酒组*/
2-
/*干杯~*/
3-
var g = $.createShape({lifeTime:30,x:0,y:0});
2+
var g = $.createShape({lifeTime:360,x:0,y:0});
43
g.graphics.beginFill(0xffffff);
54
g.graphics.drawRect(0,0,540,383);
65
g.graphics.endFill();
76

7+
/*Background*/
8+
var h=$.createShape({x:0,y:0,alpha:0.5,lifeTime:300,motion:{
9+
alpha:{fromValue:0,toValue:0.5,lifeTime:1}}
10+
});
11+
h.graphics.beginFill(0x000000);
12+
h.graphics.drawRect(-5,-5,547,390);
13+
h.graphics.endFill();
14+
15+
16+
var g = $.createShape({x:-20,y:-20,lifeTime:300,motion:{
17+
alpha:{fromValue:0,toValue:0.99,lifeTime:1}}
18+
});
19+
g.graphics.beginFill(0xffffff);
20+
g.graphics.drawEllipse(10,16,560,380);
21+
g.graphics.endFill();
22+
g.filters=[$.createGlowFilter(0xFFFFFF,0.5,50,50,2,6,false,false),$.createBlurFilter(160,160)];
23+
24+
var g = $.createShape({lifeTime:360,x:0,y:0,alpha:0.2,motion:{
25+
alpha:{fromValue:0,toValue:0.2,lifeTime:1}}
26+
});
27+
g.graphics.beginFill(0x996600);
28+
g.graphics.drawRect(0,0,540,383);
29+
g.graphics.endFill()
30+
31+
/*马猴烧酒组*/
832
var s = $.createShape({lifeTime:10,motionGroup:[
933
{x:{fromValue:5,toValue:0,lifeTime:2},alpha:{fromValue:0,toValue:1,lifeTime:2}},
1034
{x:{fromValue:0,toValue:-15,lifeTime:6}},

0 commit comments

Comments
 (0)