mirror of
https://github.com/taigrr/gico.git
synced 2026-04-01 18:58:59 -07:00
finish merging
This commit is contained in:
@@ -54,10 +54,10 @@ func GetYearSVG(frequencies []int) bytes.Buffer {
|
||||
for _, f := range frequencies {
|
||||
squareColors = append(squareColors, common.ColorForFrequency(f, min, max))
|
||||
}
|
||||
return drawYearImage(squareColors)
|
||||
return drawYearImage(squareColors, frequencies)
|
||||
}
|
||||
|
||||
func drawYearImage(c []sc.SimpleColor) bytes.Buffer {
|
||||
func drawYearImage(c []sc.SimpleColor, freq []int) bytes.Buffer {
|
||||
var sb bytes.Buffer
|
||||
sbw := bufio.NewWriter(&sb)
|
||||
squareLength := 10
|
||||
@@ -66,7 +66,7 @@ func drawYearImage(c []sc.SimpleColor) bytes.Buffer {
|
||||
canvas := svg.New(sbw)
|
||||
canvas.Start(width, height)
|
||||
for i, s := range c {
|
||||
canvas.Square(2*squareLength+width/(len(c)/7+1)*(i/7)+squareLength*2, squareLength/2+height/7*(i%7), squareLength, fmt.Sprintf("fill:%s", s.ToHex()))
|
||||
canvas.Square(2*squareLength+width/(len(c)/7+1)*(i/7)+squareLength*2, squareLength/2+height/7*(i%7), squareLength, fmt.Sprintf("fill:%s; value:%d", s.ToHex(), freq[i]))
|
||||
}
|
||||
// canvas.Text(2*squareLength, squareLength*3, "Mon", fmt.Sprintf("text-anchor:middle;font-size:%dpx;fill:black", squareLength))
|
||||
// canvas.Text(2*squareLength, int(float64(squareLength)*6.5), "Wed", fmt.Sprintf("text-anchor:middle;font-size:%dpx;fill:black", squareLength))
|
||||
|
||||
@@ -55,14 +55,14 @@ func drawYearUnicode(c []sc.SimpleColor) string {
|
||||
// o := termenv.NewOutput(os.Stdout)
|
||||
var s strings.Builder
|
||||
o := termenv.NewOutputWithProfile(os.Stdout, termenv.TrueColor)
|
||||
weeks := [7][]sc.SimpleColor{{}}
|
||||
weekRows := [7][]sc.SimpleColor{{}}
|
||||
for i := 0; i < 7; i++ {
|
||||
weeks[i] = []sc.SimpleColor{}
|
||||
weekRows[i] = []sc.SimpleColor{}
|
||||
}
|
||||
for i := range c {
|
||||
weeks[i%7] = append(weeks[i%7], c[i])
|
||||
for i := 0; i < len(c); i++ {
|
||||
weekRows[i%7] = append(weekRows[i%7], c[i])
|
||||
}
|
||||
for _, row := range weeks {
|
||||
for _, row := range weekRows {
|
||||
for w, d := range row {
|
||||
style := o.String(block).Foreground(termenv.TrueColor.Color(d.ToHex()))
|
||||
s.WriteString(style.String())
|
||||
|
||||
Reference in New Issue
Block a user