-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharts.go
34 lines (30 loc) · 795 Bytes
/
charts.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
package main
import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/vector"
"image/color"
)
func drawCharts(screen *ebiten.Image, data [][]float64, startY []int, color color.RGBA) {
for i := 0; i < len(data); i++ {
for v := range data[i] {
vector.DrawFilledRect(screen, float32(870+v), float32(startY[i]-int(data[i][v]*15)), 2, 2, color, false)
}
}
}
func drawDistributionBars(screen *ebiten.Image, x, y int, traitValues [8]int, animalsLen int, color color.RGBA) {
for k := 0; k < 8; k++ {
height := int(float64(traitValues[k]) * 100.0 / float64(animalsLen))
if height < 1 {
height = 1
}
vector.DrawFilledRect(
screen,
float32(x)+4.0+20.0*float32(k),
float32(y+100-int(height)),
16,
float32(height),
color,
false,
)
}
}