Pure Clojure core for Olympus grid view layout calculation.
Layout algorithm: n=1: {:rows 1 :cols 1} ; full screen n=2: {:rows 1 :cols 2} ; side-by-side n=3: {:rows 2 :cols 2 :empty #{[1 1]}} ; 2+1 n=4: {:rows 2 :cols 2} ; 2x2 n=5+: {:tabs (ceil n/4) :per-tab 4} ; tabbed
Pure Clojure core for Olympus grid view layout calculation.
Layout algorithm:
n=1: {:rows 1 :cols 1} ; full screen
n=2: {:rows 1 :cols 2} ; side-by-side
n=3: {:rows 2 :cols 2 :empty #{[1 1]}} ; 2+1
n=4: {:rows 2 :cols 2} ; 2x2
n=5+: {:tabs (ceil n/4) :per-tab 4} ; tabbed(assign-positions lings layout)Assign lings to grid positions based on layout.
Arguments:
Returns: Map of {ling-id -> {:row R :col C :tab T}}
Assign lings to grid positions based on layout.
Arguments:
- lings: Sequence of ling maps with :slave/id
- layout: Layout specification from calculate-layout
Returns: Map of {ling-id -> {:row R :col C :tab T}}(calculate-layout n)Calculate optimal grid layout for n lings.
Returns layout spec:
Arguments:
Returns: Layout specification map
Calculate optimal grid layout for n lings.
Returns layout spec:
- n=0: {:rows 0 :cols 0}
- n=1: {:rows 1 :cols 1}
- n=2: {:rows 1 :cols 2}
- n=3: {:rows 2 :cols 2 :empty-cells #{[1 1]}}
- n=4: {:rows 2 :cols 2}
- n=5+: {:tabs (ceil n/4) :per-tab 4}
Arguments:
- n: Number of lings to layout
Returns: Layout specification map(grid-capacity layout)Calculate total capacity of a layout.
Arguments:
Returns: Maximum lings that fit in layout
Calculate total capacity of a layout. Arguments: - layout: Layout specification Returns: Maximum lings that fit in layout
(position-for-cell positions row col tab)Get the ling at a specific grid cell.
Arguments:
Returns: Ling ID or nil
Get the ling at a specific grid cell. Arguments: - positions: Position map from assign-positions - row: Row index (0-based) - col: Column index (0-based) - tab: Optional tab index (nil for non-tabbed) Returns: Ling ID or nil
(tabbed? layout)Check if layout uses tabs.
Arguments:
Returns: Boolean
Check if layout uses tabs. Arguments: - layout: Layout specification Returns: Boolean
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |