Add function drawWall()
This commit is contained in:
parent
4d0c4c78a6
commit
b7f2276d18
25
Main.go
25
Main.go
|
@ -117,6 +117,28 @@ func drawMonth(m time.Month, x, y int) {
|
|||
}
|
||||
|
||||
func drawWall() {
|
||||
w, h := wall.Size()
|
||||
if w < monthWidth + 2 * smallGap || h < monthHeight + 2 * smallGap + titleHeight {
|
||||
wrappedText("Екран је премали за календар.", wall, defStyle)
|
||||
return
|
||||
}
|
||||
monthsWide := (w - 2*smallGap + largeGap) / (monthWidth + largeGap)
|
||||
monthsHigh := (h - smallGap - titleHeight) / (monthHeight + smallGap)
|
||||
monthsDrawn := min(monthsHigh*monthsWide, 12) // TODO: izraziti 12 drugacije??
|
||||
|
||||
startingMonth := time.Month((int(selTime.Month()) - 1) / monthsDrawn * monthsDrawn + 1)
|
||||
endingMonth := time.Month(min(12, int(startingMonth) + monthsDrawn - 1))
|
||||
|
||||
centerVert := (w - monthsWide*monthWidth - (monthsWide-1)*largeGap) / 2
|
||||
for i, m := 0, startingMonth ; i < monthsHigh ; i++ {
|
||||
for j := 0 ; j < monthsWide ; j++ {
|
||||
drawMonth(m, centerVert + j*(monthWidth+largeGap), titleHeight + smallGap + i*(monthHeight+smallGap))
|
||||
if m >= endingMonth {
|
||||
return
|
||||
}
|
||||
m++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -135,8 +157,7 @@ func main() {
|
|||
|
||||
wall.SetStyle(defStyle)
|
||||
wall.Clear()
|
||||
drawMonth(time.January, 0, 0)
|
||||
drawMonth(time.July, monthWidth * 2, 0)
|
||||
drawWall()
|
||||
|
||||
|
||||
quit := func() {
|
||||
|
|
Loading…
Reference in a new issue