@minofrk/xelto-diagram-canvas
Version:
An implementation of <xelto-diagram> in TypeScript.
23 lines • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const scale_1 = require("../scale");
const point_ops_1 = require("../../point-ops");
function getPhysicalValues(virtualArea, canvasSize) {
const physicalScale = scale_1.getScales(canvasSize);
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 lineWidth = Math.max(1, Math.ceil(Math.max(physicalScale.x, physicalScale.y) / 15));
const gapSize = point_ops_1.square(Math.floor(lineWidth - 1) / 2);
const intLeftTop = point_ops_1.plus(point_ops_1.plus(point_ops_1.floor(point_ops_1.minus(rawCenter, rawHalfWidth)), point_ops_1.square(1 / 2)), gapSize);
const intRightBottom = point_ops_1.minus(point_ops_1.plus(point_ops_1.floor(point_ops_1.plus(rawCenter, rawHalfWidth)), point_ops_1.square(1 / 2)), gapSize);
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,
lineWidth,
};
}
exports.default = getPhysicalValues;
//# sourceMappingURL=get-physical-values.js.map