-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.go
45 lines (36 loc) · 808 Bytes
/
util.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"image/color"
"math"
"strings"
)
// give distance between two coordinates
func Distance(a, b xyi) float64 {
x := math.Abs(float64(a.X - b.X))
y := math.Abs(float64(a.Y - b.Y))
return float64(math.Sqrt(x*x + y*y))
}
// Return healthbar color
func healthColor(input float32) color.NRGBA {
var healthColor color.NRGBA = color.NRGBA{R: 255, G: 255, B: 255, A: 0}
health := input * 100
if health < 100 && health > 0 {
healthColor.A = 255
healthColor.B = 0
r := int(float32(100-(health)) * 5)
if r > 255 {
r = 255
}
healthColor.R = uint8(r)
g := int(float32(health) * 4)
if g > 255 {
g = 255
}
healthColor.G = uint8(g)
}
return healthColor
}
// Text progess dots
func makeEllipsis() string {
return strings.Repeat(".", int(aniCount.Load()%4))
}