@minofrk/xelto-diagram-canvas
Version:
An implementation of <xelto-diagram> in TypeScript.
18 lines • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const point_ops_1 = require("../../point-ops");
function toPhysicalArea(virtualArea, physicalScale) {
const rawSize = point_ops_1.elementWiseTimes(virtualArea.size, physicalScale);
const rawHalfWidth = point_ops_1.times(point_ops_1.minus(rawSize, point_ops_1.square(1)), 1 / 2);
const rawCenter = point_ops_1.plus(point_ops_1.elementWiseTimes(virtualArea.leftTop, physicalScale), rawHalfWidth);
const intLeftTop = point_ops_1.floor(point_ops_1.minus(rawCenter, rawHalfWidth));
const intRightBottom = point_ops_1.plus(point_ops_1.floor(point_ops_1.plus(rawCenter, rawHalfWidth)), point_ops_1.square(1));
const intSize = point_ops_1.minus(intRightBottom, intLeftTop);
return {
leftTop: point_ops_1.times(intSize, -1 / 2),
center: point_ops_1.times(point_ops_1.plus(intLeftTop, intRightBottom), 1 / 2),
size: intSize,
};
}
exports.default = toPhysicalArea;
//# sourceMappingURL=to-physical-area.js.map