2017-03-02 02:05:33 +00:00
|
|
|
// Origin Component
|
|
|
|
// Values are given in pixels, not percent
|
|
|
|
|
|
|
|
var Origin = {
|
|
|
|
|
2017-03-15 23:08:59 +00:00
|
|
|
originX: 0.5,
|
|
|
|
originY: 0.5,
|
|
|
|
|
|
|
|
// READ ONLY
|
|
|
|
displayOriginX: 0,
|
|
|
|
displayOriginY: 0,
|
2017-03-02 02:05:33 +00:00
|
|
|
|
|
|
|
setOrigin: function (x, y)
|
|
|
|
{
|
2017-03-15 23:08:59 +00:00
|
|
|
if (x === undefined) { x = 0.5; }
|
2017-03-02 02:05:33 +00:00
|
|
|
if (y === undefined) { y = x; }
|
|
|
|
|
|
|
|
this.originX = x;
|
|
|
|
this.originY = y;
|
|
|
|
|
2017-03-15 23:08:59 +00:00
|
|
|
this.displayOriginX = x * this.width;
|
|
|
|
this.displayOriginY = y * this.height;
|
|
|
|
|
2017-03-02 02:05:33 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
setOriginToCenter: function ()
|
|
|
|
{
|
2017-03-15 23:08:59 +00:00
|
|
|
this.setOrigin(0.5);
|
2017-03-02 02:05:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Origin;
|