Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{
startFrame = param.startFrame;
}
var endFrame = {x:-1, y:-1};
if (typeof(param.endFrame) == "number")
{
endFrame.x = param.endFrame;
endFrame.y = 1;
}
else if (param.endFrame)
{
endFrame = param.endFrame;
}
debug.assert((typeof(startFrame.x) == 'number' &&
typeof(startFrame.y) == 'number' &&
typeof(endFrame.x) == 'number' &&
typeof(endFrame.y == 'number')), "parameter error");
this._startX = startFrame.x; //* param.w;
this._startY = startFrame.y; //* param.h;
this._endX = endFrame.x == -1 ? -1 : endFrame.x;// * param.w;
this._endY = endFrame.y == -1 ? -1 : endFrame.y;// * param.h;
debug.assert(typeof(param.totalTime) == "number" && typeof(param.interval) == "number", "parameter error!");
this._totalTime = param.totalTime;
this._interval = param.interval;
if (typeof(param.factor) == 'number')
this._factor = param.factor;
else
else if (param.endFrame)
{
endFrame = param.endFrame;
}
debug.assert((typeof(startFrame.x) == 'number' &&
typeof(startFrame.y) == 'number' &&
typeof(endFrame.x) == 'number' &&
typeof(endFrame.y == 'number')), "parameter error");
this._startX = startFrame.x; //* param.w;
this._startY = startFrame.y; //* param.h;
this._endX = endFrame.x == -1 ? -1 : endFrame.x;// * param.w;
this._endY = endFrame.y == -1 ? -1 : endFrame.y;// * param.h;
debug.assert(typeof(param.totalTime) == "number" && typeof(param.interval) == "number", "parameter error!");
this._totalTime = param.totalTime;
this._interval = param.interval;
if (typeof(param.factor) == 'number')
this._factor = param.factor;
else
this._factor = function(t){return t;};
this._target.x = this._startX;
this._target.y = this._startY;
this._elapsed = 0;
this._timeline = genFrameTimeline(this._imgModel, this._hSpan, this._vSpan, this._startX, this._startY, this._endX, this._endY, this._interval, this._totalTime);
this._state = "prepared";
HonestView.register = function (type, fs)
{
assert(!hvDraw[type],type + " has already exist in draw functions table");
assert(!hvBboxTbl[type],type + " has already exist in bbox functions table");
assert(!hvInsideTbl[type],type + " has already exist in inside functions table");
hvDraw[type] = fs.draw;
hvBboxTbl[type] = fs.bbox;
hvInsideTbl[type] = fs.inside;
return fs;
}
ProcessingView.register = function (type, fs)
{
assert(!ProcessingView.hvDraw[type],type + " has already exist in draw functions table");
assert(!ProcessingView.hvBboxTbl[type],type + " has already exist in bbox functions table");
assert(!ProcessingView.hvInsideTbl[type],type + " has already exist in inside functions table");
ProcessingView.hvDraw[type] = fs.draw;
ProcessingView.hvBboxTbl[type] = fs.bbox;
ProcessingView.hvInsideTbl[type] = fs.inside;
return fs;
}
init:function(param)
{
if (Director.__instance__)
return Director.__instance__;
Director.superClass.init.call(this, param);
this._timeStamper = new TimeStamper();
this._sysPipe = pipe.createEventTrigger(this._timeStamper);
debug.assert(param.view, 'param error');
this._defaultView = param.view;
this._displayList = [];
this._now = 0;
this.registerEvents();
Director.__instance__ = this;
var self = this;
var clockf = function()
{
return self._now;
};
this._state = "running";
}
else
{
this._elapsed += this._frameData.factor(dt);
if (this._elapsed >= this._totalTime)
{
this._elapsed = this._totalTime;
this._state = "end";
}
}
var frame = this._timeline(this._elapsed/this._totalTime);
debug.assert(this._target || target, "Animation, there is no target!");
debug.assert(typeof(frame.offset.x) == "number" && typeof(frame.offset.y) == "number" && typeof(frame.size.w) == "number" && typeof(frame.size.h) == "number",
"the value which timeline calc is wrong");
this._target.w = frame.size.w;
this._target.h = frame.size.h;
this._target.x = frame.offset.x;
this._target.y = frame.offset.y;
if (this.hasCBs())
this.cb(this._elapsed/this._totalTime);
},
draw : function (m, spad)
{
var ctx = spad || this._ctx;
var t = m.get("type");
var f = hvDraw[t];
assert(f, "no draw function for type `" + t + "'");
var ap = this.anchorPoint(m);
ctx.save();
ctx.translate(-ap.x, -ap.y);
f(m, this, ctx);
ctx.restore();
},
bbox: function (m)
{
var cache = m.get("cache");
if (cache.bbox !== undefined)
{
return cache.bbox;
}
var f = hvBboxTbl[m.get("type")];
assert(f, "no bounding box calculator for the `" + m.get("type") + "' type of model");
var res = f(m, this);
if (!res.nocache)
{
cache.bbox = res;
}
else
{
cache.bbox = undefined;
}
return res;
},
this._elapsed = 0;
this._state = "running";
}
else
{
this._elapsed += this._frameData.factor(dt);
if (this._elapsed >= this._totalTime)
{
this._elapsed = this._totalTime;
this._state = "end";
}
}
var frame = this._timeline(this._elapsed/this._totalTime);
debug.assert(this._target || target, "Animation, there is no target!");
debug.assert(typeof(frame.offset.x) == "number" && typeof(frame.offset.y) == "number" && typeof(frame.size.w) == "number" && typeof(frame.size.h) == "number",
"the value which timeline calc is wrong");
this._target.w = frame.size.w;
this._target.h = frame.size.h;
this._target.x = frame.offset.x;
this._target.y = frame.offset.y;
if (this.hasCBs())
this.cb(this._elapsed/this._totalTime);
},
var beginDrawMode = function (m, ctx)
{
var oldStyles = {fill:ctx.fillStyle, stroke:ctx.strokeStyle};
var fillc = m.get("fill");
debug.assert(typeof(fillc) == "string" || fillc == undefined, "color format changed to rgb(0, 0, 0)");
if (fillc !== undefined)
{
ctx.fillStyle = fillc;
}
var sc = m.get("stroke");
if (sc !== undefined)
{
ctx.strokeStyle = sc;
}
return oldStyles;
}