js2flowchart
Version:
> Why? While I've been working on [Under-the-hood-ReactJS](https://github.com/Bogdan-Lyashenko/Under-the-hood-ReactJS) I spent enormous amount of time on creating schemes. Each change in code or flowchart affects all entire scheme instantly, forcing you t
44 lines • 908 B
JavaScript
export var calculateShapesBoundaries = function calculateShapesBoundaries(list) {
if (!list || !list.length) {
throw new Error('List is not specified.');
}
var first = list[0];
var minX = first.min.x,
maxX = first.max.x,
minY = first.min.y,
maxY = first.max.y;
list.forEach(function (_ref) {
var min = _ref.min,
max = _ref.max;
if (min.x < minX) {
minX = min.x;
}
if (min.y < minY) {
minY = min.y;
}
if (max.x > maxX) {
maxX = max.x;
}
if (max.y > maxY) {
maxY = max.y;
}
});
return {
min: {
x: minX,
y: minY
},
max: {
x: maxX,
y: maxY
}
};
};
export var addOffsetToPoints = function addOffsetToPoints(points, offsetPoint) {
return [].concat(points).map(function (point) {
return {
x: point.x + offsetPoint.x,
y: point.y + offsetPoint.y
};
});
};