all files / graphics/ unit-convertor.js

57.14% Statements 12/21
100% Branches 0/0
28.57% Functions 2/7
57.14% Lines 12/21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38                                                    
define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PdfUnitConverter = (function () {
        function PdfUnitConverter(dpi) {
            this.updateProportionsHelper(dpi);
        }
        PdfUnitConverter.prototype.convertUnits = function (value, from, to) {
            return this.convertFromPixels(this.convertToPixels(value, from), to);
        };
        PdfUnitConverter.prototype.convertToPixels = function (value, from) {
            var index = from;
            var result = (value * this.proportions[index]);
            return result;
        };
        PdfUnitConverter.prototype.convertFromPixels = function (value, to) {
            var index = to;
            var result = (value / this.proportions[index]);
            return result;
        };
        PdfUnitConverter.prototype.updateProportionsHelper = function (pixelPerInch) {
            this.proportions = [
                pixelPerInch / 2.54,
                pixelPerInch / 6.0,
                1,
                pixelPerInch / 72.0,
                pixelPerInch,
                pixelPerInch / 300.0,
                pixelPerInch / 25.4
            ];
        };
        PdfUnitConverter.horizontalResolution = 96;
        PdfUnitConverter.verticalResolution = 96;
        return PdfUnitConverter;
    }());
    exports.PdfUnitConverter = PdfUnitConverter;
});