-
Notifications
You must be signed in to change notification settings - Fork 0
/
racetimer.go
27 lines (20 loc) · 866 Bytes
/
racetimer.go
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
27
package racetimer
import "image"
import "image/color"
import "github.com/hajimehoshi/ebiten/v2"
import "github.com/tinne26/luckyfeet/src/lib/text"
import "github.com/tinne26/luckyfeet/src/game/context"
import "github.com/tinne26/luckyfeet/src/game/utils"
func Draw(canvas *ebiten.Image, ctx *context.Context, ticks int) {
white := color.RGBA{244, 244, 244, 244} // slightly translucid
black := color.RGBA{ 16, 16, 16, 255}
scale := 2
pad := 4
vertBoxOffset := 5
horzBoxOffset := 8
var txt []string = []string{ utils.FmtTicksToTimeStrSecs(ticks) }
txtWidth := text.MeasureLineWidth(txt[0], scale)
rect := image.Rect(pad, pad, pad + txtWidth + horzBoxOffset*2, pad + text.LineHeight*scale + vertBoxOffset*2)
text.DrawRectBox(canvas, rect, 1, white, black, scale)
text.DrawAt(canvas, pad + horzBoxOffset, pad + vertBoxOffset, txt, black, scale)
}