チェンジセット 1489
- コミット日時:
- 2008/10/02 21:00:22 (4 年前)
- ファイル:
-
- ruby/jsplash/trunk/client2/demo_20081001/asblock.js (更新) (1 diff)
- ruby/jsplash/trunk/client2/index.xml (更新) (1 diff)
- ruby/jsplash/trunk/client2/jsplash/objects.js (更新) (10 diffs)
- ruby/jsplash/trunk/client2/jsplash/player.js (更新) (1 diff)
- ruby/jsplash/trunk/client2/jsplash/shaperenderer.js (更新) (19 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
ruby/jsplash/trunk/client2/demo_20081001/asblock.js
r1479 r1489 12 12 onEnterFrame = function () { 13 13 if (!this.a_set) { 14 _x = Math.random() * 700 - 30;15 _y = -70 - Math.random() * 460;14 this._x = Math.random() * 700 - 30; 15 this._y = -70 - Math.random() * 460; 16 16 this.ay = Math.random() * 4 + 5; 17 17 this.ax = Math.random() * 7 - 3; ruby/jsplash/trunk/client2/index.xml
r1478 r1489 53 53 <div id="progbar"><div> </div></div> 54 54 <p id="statusout"> </p> 55 <p id="sout">starting <em>JSplash Player 0.2. 2</em>...<br />-------------------------------------<br /></p>55 <p id="sout">starting <em>JSplash Player 0.2.4</em>...<br />-------------------------------------<br /></p> 56 56 <svg id="svgrt" xmlns="http://www.w3.org/2000/svg" style="width: 100px; height: 100px;"> 57 57 </svg> ruby/jsplash/trunk/client2/jsplash/objects.js
r1478 r1489 6 6 JSplash.injectScriptVariables = function(func, vlist) { 7 7 var decls = ["\n"]; 8 var saves = [" \n"];8 var saves = ["}\n"]; 9 9 var len = vlist.length; 10 10 … … 13 13 saves.push("this.__locals__['"+vlist[i]+"'] = "+vlist[i]+";\n"); 14 14 } 15 16 decls.push("with(this){\n"); 17 15 18 16 19 var func2; … … 233 236 this.updateProxy(); 234 237 235 var vlist = P.thisMembersList();238 var vlist = []; // P.thisMembersList(); 236 239 var len, i; 237 240 … … 240 243 vlist.push(objname); 241 244 this.getProxy().__locals__[objname] = this.nameMap[objname].getProxy(); 242 this.getProxy(). setChidrenRefs();245 this.getProxy().__setChidrenRefs__(); 243 246 } 244 247 … … 266 269 } 267 270 268 P.setThisObjects(); 269 P.saveBindedLocal(); 271 //P.setThisObjects(); 272 //P.saveBindedLocal(); 273 P.__prepareImplicitThis__(); 270 274 try { 271 275 act.tweaked_action(); … … 274 278 console.log("[AS] " + e); 275 279 } 276 P.pickBindedLocal();280 //P.pickBindedLocal(); 277 281 this.applyProxyChanges(); 278 282 … … 465 469 this.__locals__ = {}; 466 470 this.__old_locals__ = {}; 467 this.setThisObjects();468 }, 469 470 setChidrenRefs: function() {471 //this.setThisObjects(); 472 }, 473 474 __setChidrenRefs__: function() { 471 475 var m = this.owner.nameMap; 472 476 for (var name in m) { … … 474 478 { 475 479 this[name] = m[name].getProxy(); 476 this[name]. setChidrenRefs();480 this[name].__setChidrenRefs__(); 477 481 m[name].updateProxy(); 478 482 } … … 480 484 }, 481 485 486 __prepareImplicitThis__: function() { 487 if (!this.onEnterFrame) 488 this.onEnterFrame = null; 489 }, 490 491 /* 482 492 setThisObjects: function() { 483 493 var thislist = this.thisMembersList(); … … 505 515 }, 506 516 517 518 thisMembersList: function() { 519 return ['play', 'stop', '_parent', 'gotoAndPlay', 'gotoAndStop', 'onEnterFrame', '_x', '_y', '_rotation', '_xscale', '_yscale']; 520 }, 521 522 */ 523 507 524 type_of: function() { 508 525 return this.owner.klass.swf_object_type; 509 },510 511 thisMembersList: function() {512 return ['play', 'stop', '_parent', 'gotoAndPlay', 'gotoAndStop', 'onEnterFrame', '_x', '_y', '_rotation', '_xscale', '_yscale'];513 526 }, 514 527 ruby/jsplash/trunk/client2/jsplash/player.js
r1464 r1489 16 16 this.executor.frameRate = swf.frameRate; 17 17 this.svg = svg; 18 JSplash.createFillDef(svg); 18 19 19 20 svg.style.width = swf.pxWidth + "px"; ruby/jsplash/trunk/client2/jsplash/shaperenderer.js
r1478 r1489 2 2 JSplash.ShapeRenderer.prototype = { 3 3 initialize: function(source) { 4 this.shape_id = source.id; 4 5 this.edgeStyles = source.line_styles.slice(); 5 6 this.fillStyles = source.fill_styles; … … 8 9 this.rightFillEdges = {}; 9 10 this.edgeList = []; 11 this.displayList = null; 10 12 11 13 this.fillLoops = null; 12 14 this.te_id = 0; 15 this.fillDefMap = {}; 16 }, 17 18 lookupFillId: function(fi) { 19 if (!JSplash.defsElement) 20 return null; 21 22 if (this.fillDefMap[fi]) { 23 return this.fillDefMap[fi]; 24 } 25 26 var fid = "gf"+this.shape_id+"_"+fi; 27 var filldata = this.fillStyles[fi-1]; 28 if (!filldata.grad) 29 return null; 30 31 var attrs = {id: fid, gradientUnits: 'userSpaceOnUse', x1: -819, x2: 819}; 32 if (filldata.mov || filldata.scl || filldata.skw) { 33 var M =[1, 0, 0, 1, 0, 0]; 34 if (filldata.mov) { 35 M[4] = JSplash.$twips(filldata.mov[0]); 36 M[5] = JSplash.$twips(filldata.mov[1]); 37 } 38 39 if (filldata.scl) { 40 M[0] = filldata.scl[0]; 41 M[3] = filldata.scl[1]; 42 } 43 44 if (filldata.skw) { 45 M[1] = filldata.skw[0]; 46 M[2] = filldata.skw[1]; 47 } 48 49 attrs.gradientTransform = "matrix("+M.join(' ')+")"; 50 } 51 52 var gdef = JSplash.$svg("linearGradient", attrs); 53 JSplash.defsElement.appendChild(gdef); 54 55 56 var len = filldata.s.length; 57 for (var i = 0;i < len;i++) { 58 var stp = JSplash.$svg("stop", {'stop-color': ('#'+filldata.c[i]), offset: (filldata.s[i] / 255)}); 59 gdef.appendChild(stp); 60 } 61 62 this.fillDefMap[fi] = fid; 63 return fid; 13 64 }, 14 65 … … 25 76 var _ty = 0; 26 77 var _first_seg = true; 78 79 var order_index = 0; 27 80 28 81 var x1, y1; … … 64 117 65 118 if (rcd.f0 != undefined) { 66 cur_leftFill = rcd.f0 + fs_ofs;119 cur_leftFill = rcd.f0 ? (rcd.f0 + fs_ofs) : 0; 67 120 } 68 121 69 122 if (rcd.f1 != undefined) { 70 cur_rightFill = rcd.f1 + fs_ofs;123 cur_rightFill = rcd.f1 ? (rcd.f1 + fs_ofs) : 0; 71 124 } 72 125 73 126 if (rcd.ls != undefined) { 74 cur_lineStyle = rcd.ls + es_ofs;127 cur_lineStyle = rcd.ls ? (rcd.ls + es_ofs) : 0; 75 128 } 76 129 } … … 87 140 _ty = y2 + rcd.p[3]; 88 141 89 this.addCurve( _first_seg, cur_lineStyle, cur_leftFill, cur_rightFill, x1, y1, x2, y2, _tx, _ty);142 this.addCurve(order_index++, _first_seg, cur_lineStyle, cur_leftFill, cur_rightFill, x1, y1, x2, y2, _tx, _ty); 90 143 } 91 144 else … … 97 150 _ty += rcd.p[1]; 98 151 99 this.addLine( _first_seg, cur_lineStyle, cur_leftFill, cur_rightFill, x1, y1, _tx, _ty);152 this.addLine(order_index++, _first_seg, cur_lineStyle, cur_leftFill, cur_rightFill, x1, y1, _tx, _ty); 100 153 } 101 154 … … 107 160 }, 108 161 109 addLine: function( fst, ls, fL, fR, x1, y1, x2, y2) {162 addLine: function(oi, fst, ls, fL, fR, x1, y1, x2, y2) { 110 163 var E = new JSplash.EdgePart(false, ls, fst); 164 E.oi = oi; 111 165 E.tx1 = x1; 112 166 E.ty1 = y1; … … 117 171 }, 118 172 119 addCurve: function( fst, ls, fL, fR, x1, y1, cx, cy, x2, y2) {173 addCurve: function(oi, fst, ls, fL, fR, x1, y1, cx, cy, x2, y2) { 120 174 var E = new JSplash.EdgePart(true, ls, fst); 175 E.oi = oi; 121 176 E.tx1 = x1; 122 177 E.ty1 = y1; … … 149 204 }, 150 205 206 buildDrawOrder: function() { 207 if (this.displayList) 208 return; 209 210 var loopss = this.fillLoops; 211 if (!loopss) return; 212 213 this.displayList = []; 214 var len, i, llen, k, E, lps, fi; 215 216 var elist = this.edgeList; 217 218 // gather head edges of polylines 219 len = elist.length; 220 for (i = 0;i < len;i++) { 221 E = elist[i]; 222 if (!E.isFirst) continue; 223 224 this.displayList.push(new JSplash.DisplayListEntry(0, i, E.oi+1)); 225 } 226 227 var ent; 228 // gather fill loops 229 len = loopss.length; 230 for (i = 0;i < len;i++) { 231 lps = loopss[i].loops; 232 llen = lps.length; 233 fi = loopss[i].fill_index; 234 235 ent = new JSplash.DisplayListEntry(1, lps, lps[0][0].original.oi); 236 ent.fill_index = fi; 237 this.displayList.push(ent); 238 239 /* 240 for (k = 0;k < llen;k++) { 241 ent = new JSplash.DisplayListEntry(1, lps[k], lps[k][0].original.oi); 242 ent.fill_index = fi; 243 console.log(fi); 244 this.displayList.push(ent); 245 }*/ 246 } 247 248 this.displayList.sort(this.osorter); 249 }, 250 251 renderDisplayList: function(g) { 252 if (!this.displayList) 253 return; 254 255 var list = this.displayList; 256 var len = list.length; 257 var di; 258 259 for (var i = 0;i < len;i++) { 260 di = list[i]; 261 if (di.type == 0) 262 this.buildEdges(g, di.obj, -1); 263 else { 264 this.buildAFill(di.obj, di.fill_index, g); 265 } 266 } 267 }, 268 269 osorter: function (a,b) { 270 return a.index - b.index; 271 }, 272 151 273 buildFills: function(g) { 152 274 var loopss = this.fillLoops; … … 158 280 this.buildAFill(loopss[i].loops, this.fillStyles[loopss[i].fill_index-1], g); 159 281 } 160 }, 161 162 buildAFill: function(list, style, g) { 282 /* 283 284 var elist = this.edgeList; 285 var next_fi = null; 286 var edge_start = 0; 287 var edge_end = elist.length; 288 289 if (this.layerStartIndices.length) 290 { 291 next_fi = this.layerStartIndices[0].fi; 292 edge_end = this.layerStartIndices[0].ei; 293 this.layerStartIndices.shift(); 294 } 295 296 297 for (var i = 0;i < len;i++) { 298 if (next_fi && loopss[i].fill_index >= next_fi) { 299 this.buildEdges(g, edge_start, edge_end); 300 301 edge_start = edge_end; 302 if (this.layerStartIndices.length) { 303 next_fi = this.layerStartIndices[0].fi; 304 edge_end = this.layerStartIndices[0].ei; 305 this.layerStartIndices.shift(); 306 } 307 else { 308 next_fi = null; 309 edge_end = elist.length; 310 } 311 312 } 313 314 this.buildAFill(loopss[i].loops, this.fillStyles[loopss[i].fill_index-1], g); 315 } 316 317 this.buildEdges(g, edge_start, edge_end);*/ 318 }, 319 320 buildAFill: function(list, fi, g) { 321 var style = this.fillStyles[fi-1]; 163 322 if (!style) return; 164 323 … … 166 325 if (style.rgb) 167 326 style_str = '#'+style.rgb; 327 else if (style.grad) 328 style_str = 'url(#' + this.lookupFillId(fi)+')'; 168 329 169 330 if (!style_str) return; … … 199 360 g.appendChild( JSplash.$svg('path', {d: commands.join(' '), fill: style_str}) ); 200 361 }, 201 202 buildSVG: function(g) { 203 this.buildFills(g); 204 362 363 buildALoop: function(lp, style, g) { 364 if (!style) return; 365 366 var style_str = null; 367 if (style.rgb) 368 style_str = '#'+style.rgb; 369 370 if (!style_str) return; 371 var E; 372 var commands = [], k; 373 var llen = lp.length; 374 for (k = 0;k < llen;k++) { 375 E = lp[k]; 376 E.calcPx(); 377 if (k==0) 378 commands.push('M '+E.px1+','+E.py1); 379 380 if (E.original.curved) { 381 commands.push('Q ' + E.pxC +','+ E.pyC); 382 commands.push(E.px2 +','+ E.py2); 383 } 384 else 385 commands.push('L ' + E.px2 +','+ E.py2); 386 } 387 388 commands.push('Z'); 389 g.appendChild( JSplash.$svg('path', {d: commands.join(' '), fill: style_str}) ); 390 }, 391 392 buildEdges: function(g, edge_start, edge_end) { 205 393 var E; 206 394 var edges = this.edgeList; … … 212 400 var curStyle = null; 213 401 214 for (var i = 0;i < len;i++) { 402 var oneshot = 0; 403 if (edge_end < 0) { 404 edge_end = edges.length; 405 oneshot = 1; 406 } 407 408 for (var i = edge_start;i < edge_end;i++) { 215 409 E = edges[i]; 216 410 E.calcPx(); … … 223 417 paths.push(JSplash.$svg('path', {d: commands.join(' '), fill: 'none', stroke: curStyle, 'stroke-width': curWidth})); 224 418 } 419 420 if (oneshot == 2) 421 break; 225 422 226 423 if (E.lineStyle) { … … 229 426 curStyle = '#' + this.edgeStyles[ E.lineStyle-1 ].rgb; 230 427 } 428 429 if (oneshot == 1) 430 oneshot = 2; 231 431 } 232 432 … … 248 448 for (;paths.length;) 249 449 g.appendChild(paths.shift()); 250 450 }, 451 452 buildSVG: function(g) { 453 this.buildDrawOrder(); 454 this.renderDisplayList(g); 251 455 return g; 252 456 }, … … 395 599 } 396 600 601 JSplash.DisplayListEntry = function(t, obj, i) { 602 this.index = i; 603 this.type = t; /* 0: edge 1: fill loop */ 604 this.obj = obj; 605 this.fill_index = 0; 606 } 607 397 608 JSplash.EdgePart = function(cv, ls, first) { 398 609 this.isFirst = first; … … 400 611 this.lineStyle = ls; 401 612 this.px1 = null; 613 this.oi = 0; 402 614 /* tx1, ty1, tx2, ty2, txC, tyC */ 403 615 } … … 449 661 } 450 662 451 663 JSplash.createFillDef = function(svg) { 664 if (!JSplash.defsElement) { 665 var defs = JSplash.$svg('defs'); 666 svg.appendChild(defs); 667 JSplash.defsElement = defs; 668 } 669 } 452 670 453 671 JSplash.EdgePart.prototype.calcPx = function() {

