blob: 0508e627d74a54c6d7b74360210dbda7be5cced7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package cmd
import (
"github.com/nsfisis/term-clock/internal/term"
)
func calcSquareSize(scr *term.Screen) (int, int, int, int) {
// Calculate square width/height and offset.
scrW, scrH := scr.Size()
// 17
// <--------------->
// ### ### ### ### ^
// # # # # # # # # # |
// # # # # # # # # | 5
// # # # # # # # # # |
// ### ### ### ### v
squareW := scrW / (17 + 2)
squareH := min(scrH/(5+2), squareW)
if squareW > squareH*3/2 {
squareW = squareH * 3 / 2
}
xOffset := (scrW - squareW*17) / 2
yOffset := (scrH - squareH*5) / 2
return squareW, squareH, xOffset, yOffset
}
|