diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-08-24 15:13:09 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-08-24 15:13:09 -0400 |
| commit | e725799ad17c575a7a3cd2536f57bd82f85782e5 (patch) | |
| tree | 4f4003524316d5a8a1d92ec33c71ed5a3aeb5a31 /layout/split.go | |
| parent | a8a38817d7bdd7505a7156e390460d48863a6bb3 (diff) | |
| download | gui-e725799ad17c575a7a3cd2536f57bd82f85782e5.zip | |
adapt grid to new layout design
Diffstat (limited to 'layout/split.go')
| -rw-r--r-- | layout/split.go | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/layout/split.go b/layout/split.go deleted file mode 100644 index db04225..0000000 --- a/layout/split.go +++ /dev/null @@ -1,26 +0,0 @@ -package layout - -import "fmt" - -// SplitFunc represents a way to split a space among a number of elements. -// The length of the returned slice must be equal to the number of elements. -// The sum of all elements of the returned slice must be eqal to the space. -type SplitFunc func(elements int, space int) []int - -var _ SplitFunc = EvenSplit - -// EvenSplit is a SplitFunc used to split a space (almost) evenly among the elements. -// It is almost evenly because width may not be divisible by elements. -func EvenSplit(elements int, width int) []int { - if elements <= 0 { - panic(fmt.Errorf("EvenSplit: elements must be greater than 0")) - } - ret := make([]int, elements) - for elements > 0 { - v := width / elements - width -= v - elements -= 1 - ret[elements] = v - } - return ret -} |