mirror of
https://github.com/taigrr/gico.git
synced 2026-04-02 03:09:07 -07:00
update ref to sc
This commit is contained in:
@@ -6,11 +6,13 @@ import (
|
||||
"math"
|
||||
"sync"
|
||||
|
||||
sc "github.com/taigrr/go-colorpallettes/simplecolor"
|
||||
sc "github.com/taigrr/simplecolorpalettes"
|
||||
)
|
||||
|
||||
var colorsLoaded sync.Once
|
||||
var colorScheme []sc.SimpleColor
|
||||
var (
|
||||
colorsLoaded sync.Once
|
||||
colorScheme []sc.SimpleColor
|
||||
)
|
||||
|
||||
func CreateGraph() bytes.Buffer {
|
||||
var x bytes.Buffer
|
||||
@@ -50,6 +52,7 @@ func ColorForFrequency(freq, min, max int) sc.SimpleColor {
|
||||
}
|
||||
return colorScheme[colorIndex]
|
||||
}
|
||||
|
||||
func MinMax(f []int) (int, int) {
|
||||
min, max := math.MaxInt, math.MinInt
|
||||
for _, x := range f {
|
||||
|
||||
4
go.mod
4
go.mod
@@ -2,8 +2,6 @@ module github.com/taigrr/gitgraph
|
||||
|
||||
go 1.19
|
||||
|
||||
replace github.com/taigrr/go-colorpallettes => ../go-colorpallettes
|
||||
|
||||
replace github.com/muesli/termenv => github.com/taigrr/termenv v0.11.2
|
||||
|
||||
require (
|
||||
@@ -12,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/go-colorpallettes v0.0.0-00010101000000-000000000000
|
||||
github.com/taigrr/simplecolorpalettes v0.9.5
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
6
go.sum
6
go.sum
@@ -18,9 +18,9 @@ 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/termenv v0.11.2 h1:oqZR08HjGIzFWml4ROmoFvWi3KRG4UZYTPRrI9/lrPA=
|
||||
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/taigrr/termenv v0.11.2/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
@@ -45,11 +45,9 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbuf
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
12
svg/svg.go
12
svg/svg.go
@@ -13,11 +13,13 @@ import (
|
||||
"github.com/srwiley/oksvg"
|
||||
"github.com/srwiley/rasterx"
|
||||
"github.com/taigrr/gitgraph/common"
|
||||
sc "github.com/taigrr/go-colorpallettes/simplecolor"
|
||||
sc "github.com/taigrr/simplecolorpalettes"
|
||||
)
|
||||
|
||||
var colorsLoaded sync.Once
|
||||
var colorScheme []sc.SimpleColor
|
||||
var (
|
||||
colorsLoaded sync.Once
|
||||
colorScheme []sc.SimpleColor
|
||||
)
|
||||
|
||||
func GetWeekSVG(frequencies []int) bytes.Buffer {
|
||||
squareColors := []sc.SimpleColor{}
|
||||
@@ -44,6 +46,7 @@ func drawWeekImage(c []sc.SimpleColor) bytes.Buffer {
|
||||
sbw.Flush()
|
||||
return sb
|
||||
}
|
||||
|
||||
func GetYearSVG(frequencies []int) bytes.Buffer {
|
||||
squareColors := []sc.SimpleColor{}
|
||||
min, max := common.MinMax(frequencies)
|
||||
@@ -54,7 +57,7 @@ func GetYearSVG(frequencies []int) bytes.Buffer {
|
||||
}
|
||||
|
||||
func drawYearImage(c []sc.SimpleColor) bytes.Buffer {
|
||||
//TODO here, draw suqares in appropriate colors, hopefully as an svg
|
||||
// TODO here, draw suqares in appropriate colors, hopefully as an svg
|
||||
var sb bytes.Buffer
|
||||
sbw := bufio.NewWriter(&sb)
|
||||
squareLength := 10
|
||||
@@ -72,6 +75,7 @@ func drawYearImage(c []sc.SimpleColor) bytes.Buffer {
|
||||
sbw.Flush()
|
||||
return sb
|
||||
}
|
||||
|
||||
func svgToPng() {
|
||||
w, h := 512, 512
|
||||
|
||||
|
||||
14
term/term.go
14
term/term.go
@@ -7,11 +7,13 @@ import (
|
||||
|
||||
"github.com/muesli/termenv"
|
||||
"github.com/taigrr/gitgraph/common"
|
||||
sc "github.com/taigrr/go-colorpallettes/simplecolor"
|
||||
sc "github.com/taigrr/simplecolorpalettes"
|
||||
)
|
||||
|
||||
var colorsLoaded sync.Once
|
||||
var colorScheme []sc.SimpleColor
|
||||
var (
|
||||
colorsLoaded sync.Once
|
||||
colorScheme []sc.SimpleColor
|
||||
)
|
||||
|
||||
func GetWeekUnicode(frequencies []int) {
|
||||
squareColors := []sc.SimpleColor{}
|
||||
@@ -21,8 +23,9 @@ func GetWeekUnicode(frequencies []int) {
|
||||
}
|
||||
drawWeekUnicode(squareColors)
|
||||
}
|
||||
|
||||
func drawWeekUnicode(c []sc.SimpleColor) {
|
||||
//o := termenv.NewOutput(os.Stdout)
|
||||
// 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()))
|
||||
@@ -44,8 +47,9 @@ func GetYearUnicode(frequencies []int) {
|
||||
}
|
||||
drawYearUnicode(squareColors)
|
||||
}
|
||||
|
||||
func drawYearUnicode(c []sc.SimpleColor) {
|
||||
//o := termenv.NewOutput(os.Stdout)
|
||||
// o := termenv.NewOutput(os.Stdout)
|
||||
o := termenv.NewOutputWithProfile(os.Stdout, termenv.TrueColor)
|
||||
weeks := [7][]sc.SimpleColor{{}}
|
||||
for i := 0; i < 7; i++ {
|
||||
|
||||
Reference in New Issue
Block a user