Browse files

Added new tags, refactored some code

  • Loading branch information...
1 parent 1e42f93 commit d3042386e3823a7edc1a4bf2576c72cfbafe9d70 Tobias Schneider committed Jan 18, 2010
Showing with 45 additions and 27 deletions.
  1. +1 −1 gordon.js
  2. +24 −20 src/Movie.js
  3. +4 −5 src/Stream.js
  4. +16 −1 src/SvgRenderer.js
View
2 gordon.js
@@ -25,7 +25,7 @@
_g.require = function(url){
if(!url.match(/\.([^\/]*)$/)){ url += ".js"; }
if(!_loadedUrls[url]){
- with(_g.xhr("GET", _g.ROOT + url, false)){
+ with(_g.xhr("GET", _g.ROOT + url + '?' + Math.random(), false)){
send(null);
if(status == 200){
eval(responseText);
View
44 src/Movie.js
@@ -176,16 +176,7 @@ Gordon.require("src/Stream");
}
x2 = Math.round(x2 * 100) / 100;
y2 = Math.round(y2 * 100) / 100;
- segment.push({
- i: i++,
- f: isFirst,
- x1: x1,
- y1: y1,
- cx: cx,
- cy: cy,
- x2: x2,
- y2: y2
- });
+ segment.push({i: i++, f: isFirst, x1: x1, y1: y1, cx: cx, cy: cy, x2: x2, y2: y2});
isFirst = false;
}else{
isFirst = true;
@@ -462,7 +453,8 @@ Gordon.require("src/Stream");
if(!d[id]){
var button = d[id] = {
type: "button",
- id: id
+ id: id,
+ cxform: new Gordon.Cxform({multR: 0.5, multG: 0.5, multB: 0.5})
};
var states = button.states = {};
do{
@@ -715,6 +707,25 @@ Gordon.require("src/Stream");
return t;
},
+ _handleDefineShape2: function(){
+ this._handleDefineShape.apply(this, arguments);
+ return this;
+ },
+
+ _handleDefineButtonCxform: function(offset, length){
+ var s = this.stream;
+ var buttonId = s.readUI16();
+ var button = this._dictionary[buttonId];
+ if(!button.cxform){ button.cxform = new Gordon.Cxform(s.readCxform()); }
+ else{ s.seek(length - 2); }
+ return this;
+ },
+
+ _handleProtect: function(offset, length){
+ this.stream.seek(length);
+ return this;
+ },
+
prevFrame: function(){
this.goto(this.currentFrame - 1);
return this;
@@ -748,15 +759,8 @@ Gordon.require("src/Stream");
};
function _cloneEdge(edge){
- return {
- i: edge.i,
- f: edge.f,
- x1: edge.x1,
- y1: edge.y1,
- cx: edge.cx,
- cy: edge.cy,
- x2: edge.x2,
- y2: edge.y2
+ with(edge){
+ return {i: i, f: f, x1: x1, y1: y1, cx: cx, cy: cy, x2: x2, y2: y2};
}
}
View
9 src/Stream.js
@@ -10,7 +10,7 @@ Gordon.require("src/inflate");
(function(){
var _g = Gordon;
var _t2p = _g.twips2px;
-
+
_g.Stream = function(url){
var xhr = Gordon.xhr("GET", url, false);
xhr.overrideMimeType("text/plain; charset=x-user-defined");
@@ -49,8 +49,8 @@ Gordon.require("src/inflate");
readSNumber: function(numBytes){
var value = this.readNumber(numBytes);
- var mask = 0x01 << (numBytes * 8 - 1);
- if(value & mask){ value = (~value + 1) * -1; }
+ var numBits = numBytes * 8;
+ if(value >> (numBits - 1)){ value -= Math.pow(2, numBits); }
return value;
},
@@ -171,8 +171,7 @@ Gordon.require("src/inflate");
readSB: function(numBits){
var value = this.readUB(numBits);
- var mask = 0x01 << (numBits - 1);
- if(value & mask){ value -= Math.pow(2, numBits); }
+ if(value >> (numBits - 1)){ value -= Math.pow(2, numBits); }
return value;
},
View
17 src/SvgRenderer.js
@@ -151,7 +151,11 @@
var states = object.states;
for(var state in states){
var list = states[state];
- for(var depth in list){ t.defineCharacter(list[depth]); }
+ for(var depth in list){
+ var entry = _cloneCharacter(list[depth]);
+ entry.cxform = object.cxform;
+ t.defineCharacter(entry);
+ }
}
break;
case "text":
@@ -445,4 +449,15 @@
return t;
}
};
+
+ var _cloneCharacter = function(character){
+ with(character){
+ return {
+ object: object,
+ depth: depth,
+ matrix: matrix,
+ cxform: character.cxform
+ };
+ }
+ }
})();

0 comments on commit d304238

Please sign in to comment.