diff options
Diffstat (limited to 'src/layout.ts')
| -rw-r--r-- | src/layout.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/layout.ts b/src/layout.ts index 6f1fd77..fd65b87 100644 --- a/src/layout.ts +++ b/src/layout.ts @@ -8,7 +8,7 @@ import {TolNode} from './tol'; import type {TolMap} from './tol'; -import {range, arraySum, limitVals, updateAscSeq} from './util'; +import {range, arraySum, linspace, limitVals, updateAscSeq} from './util'; // Represents a node/tree that holds layout data for a TolNode node/tree export class LayoutNode { @@ -276,7 +276,10 @@ let sqrLayout: LayoutFn = function (node, pos, dims, showHeader, allowCollapse, let numChildren = node.children.length; let areaAR = newDims[0] / newDims[1]; // Aspect ratio let lowestEmpSpc = Number.POSITIVE_INFINITY, usedNumCols = 0, usedNumRows = 0, usedTileSz = 0; - for (let numCols = 1; numCols <= numChildren; numCols++){ + const MAX_TRIES = 10; // If there are many possibilities, skip some + let ptlNumCols = numChildren == 1 ? [1] : + linspace(1, numChildren, Math.min(numChildren, MAX_TRIES)).map(n => Math.floor(n)); + for (let numCols of ptlNumCols){ let numRows = Math.ceil(numChildren / numCols); let gridAR = numCols / numRows; let usedFrac = // Fraction of area occupied by maximally-fitting grid |
