update simplecolor deps

This commit is contained in:
2023-01-25 00:19:21 -08:00
parent 47f3930288
commit 09b897d3c0
5 changed files with 15 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ import (
"math"
"sync"
sc "github.com/taigrr/simplecolorpalettes"
sc "github.com/taigrr/simplecolorpalettes/simplecolor"
)
var (
@@ -21,7 +21,7 @@ func CreateGraph() bytes.Buffer {
func init() {
colors := []string{"#767960", "#a7297f", "#e8ca89", "#f5efd6", "#158266"}
// colors = []string{"#000000", "#0e4429", "#006d32", "#26a641", "#39d353"}
colors = []string{"#000000", "#0e4429", "#006d32", "#26a641", "#39d353"}
for _, c := range colors {
color := sc.FromHexString(c)
colorScheme = append(colorScheme, color)
@@ -39,8 +39,8 @@ func ColorForFrequency(freq, min, max int) sc.SimpleColor {
return sc.SimpleColor(0)
}
spread := max - min
if spread < len(colorScheme) {
return colorScheme[freq-min]
if spread < len(colorScheme)+1 {
return colorScheme[freq-min+1]
}
interval := float64(spread) / float64(len(colorScheme))
colorIndex := 0

2
go.mod
View File

@@ -10,7 +10,7 @@ require (
github.com/muesli/termenv v0.11.1
github.com/srwiley/oksvg v0.0.0-20220128195007-1f435e4c2b44
github.com/srwiley/rasterx v0.0.0-20220615024203-67b7089efd25
github.com/taigrr/simplecolorpalettes v0.9.5
github.com/taigrr/simplecolorpalettes v0.9.6
)
require (

4
go.sum
View File

@@ -18,8 +18,8 @@ github.com/srwiley/oksvg v0.0.0-20220128195007-1f435e4c2b44 h1:XPYXKIuH/n5zpUoEW
github.com/srwiley/oksvg v0.0.0-20220128195007-1f435e4c2b44/go.mod h1:cNQ3dwVJtS5Hmnjxy6AgTPd0Inb3pW05ftPSX7NZO7Q=
github.com/srwiley/rasterx v0.0.0-20220615024203-67b7089efd25 h1:uyi1c8AxAw2b9MTr639iqz45FMFb4dDR7rB++NaVooo=
github.com/srwiley/rasterx v0.0.0-20220615024203-67b7089efd25/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE=
github.com/taigrr/simplecolorpalettes v0.9.5 h1:XPyRYwCHh+0ra/7Qw5c9yQf/O4yeLkuqx2X1tVuBE2U=
github.com/taigrr/simplecolorpalettes v0.9.5/go.mod h1:MFLQqI3JOfSc+8GiO3amYfzBiozxITaQi+F1iEV8XpQ=
github.com/taigrr/simplecolorpalettes v0.9.6 h1:eEFLPdI1o34t+YHs+QlgxcpN4zOg+5S3SlWt2EMS/6o=
github.com/taigrr/simplecolorpalettes v0.9.6/go.mod h1:MFLQqI3JOfSc+8GiO3amYfzBiozxITaQi+F1iEV8XpQ=
github.com/taigrr/termenv v0.11.2 h1:oqZR08HjGIzFWml4ROmoFvWi3KRG4UZYTPRrI9/lrPA=
github.com/taigrr/termenv v0.11.2/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

View File

@@ -12,8 +12,9 @@ import (
svg "github.com/ajstarks/svgo"
"github.com/srwiley/oksvg"
"github.com/srwiley/rasterx"
sc "github.com/taigrr/simplecolorpalettes/simplecolor"
"github.com/taigrr/gitgraph/common"
sc "github.com/taigrr/simplecolorpalettes"
)
var (
@@ -40,7 +41,7 @@ func drawWeekImage(c []sc.SimpleColor) bytes.Buffer {
canvas.Start(width, height)
canvas.Rect(0, 0, width, height, "fill:black")
for i, s := range c {
canvas.Square(squareLength*2*(i+1), squareLength/2, squareLength, fmt.Sprintf("fill:%s", s.HexString()))
canvas.Square(squareLength*2*(i+1), squareLength/2, squareLength, fmt.Sprintf("fill:%s", s.ToHex()))
}
canvas.End()
sbw.Flush()
@@ -66,7 +67,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.HexString()))
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.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))

View File

@@ -6,8 +6,9 @@ import (
"sync"
"github.com/muesli/termenv"
sc "github.com/taigrr/simplecolorpalettes/simplecolor"
"github.com/taigrr/gitgraph/common"
sc "github.com/taigrr/simplecolorpalettes"
)
var (
@@ -28,7 +29,7 @@ func drawWeekUnicode(c []sc.SimpleColor) {
// o := termenv.NewOutput(os.Stdout)
o := termenv.NewOutputWithProfile(os.Stdout, termenv.TrueColor)
for w, color := range c {
style := o.String(block).Foreground(termenv.TrueColor.Color(color.HexString()))
style := o.String(block).Foreground(termenv.TrueColor.Color(color.ToHex()))
fmt.Print(style.String())
// termenv.SetForegroundColor(termenv.ForegroundColor())
if w == len(c)-1 {
@@ -60,7 +61,7 @@ func drawYearUnicode(c []sc.SimpleColor) {
}
for _, row := range weeks {
for w, d := range row {
style := o.String(block).Foreground(termenv.TrueColor.Color(d.HexString()))
style := o.String(block).Foreground(termenv.TrueColor.Color(d.ToHex()))
fmt.Print(style.String())
if w == len(row)-1 {
fmt.Println()