+/**
+ * put childrenBox inside VBox
+ */
+function putInVBox(childrenBox, parentBox) {
+ var voffset = Array(childrenBox.length).fill(0);
+ for (var i = 0; i < childrenBox.length - 1; i++) {
+ voffset[i + 1] = voffset[i] + childrenBox[i].height;
+ }
+ console.log("~", voffset);
+ for (var i = 0; i < childrenBox.length; i++) {
+ childrenBox[i] = applyVOffset(childrenBox[i], voffset[i]);
+ childrenBox[i].y += voffset[i];
+ }
+ parentBox.content = childrenBox;
+ return parentBox;
+}
+exports.putInVBox = putInVBox;
+/**
+ * apply vertical offset to a box
+ * @param box the box to be applied
+ * @param voffset the vertical offset
+ * @returns applied box
+ */
+function applyVOffset(box, voffset) {
+ if (box.y !== null) {
+ box.y += voffset;
+ }
+ if (Array.isArray(box.content)) {
+ box.content = box.content.map((x) => applyVOffset(x, voffset));
+ }
+ return box;
+}
+exports.applyVOffset = applyVOffset;