global.Measure = function Measure(sizeInPixels) {
    this._sizeInPixels = !!sizeInPixels ? sizeInPixels : 0;
};

Measure.pixelsPerInch = 96;
Measure.pointsPerInch = 72;
Measure.pointsPerPixels = Measure.pointsPerInch / Measure.pixelsPerInch;

Measure.zero = function () {
    return new Measure(0);
};

Measure.fromPixels = function (sizeInPixels) {
    return new Measure(sizeInPixels);
};

Measure.fromPoints = function (sizeInPoints) {
    if (sizeInPoints)
        return new Measure(sizeInPoints / Measure.pointsPerPixels);

    return Measure.zero();
};

Measure.prototype = {
    add: function (measure) {
        return new Measure(this._sizeInPixels + measure._sizeInPixels);
    },

    addPixels: function (pixels) {
        return new Measure(this._sizeInPixels + pixels);
    },

    addPoints: function (points) {
        return new Measure(this._sizeInPixels + points / Measure.pointsPerPixels);
    },

    toPixels: function () {
        return this._sizeInPixels + 'px';
    },

    toInches: function () {
        return (this._sizeInPixels / Measure.pixelsPerInch) + 'in';
    },

    toPoints: function () {
        return (this._sizeInPixels * Measure.pointsPerPixels) + 'pt';
    }
};