refactor: change project structure and package name

This commit is contained in:
Rico 2022-08-27 17:21:43 +02:00
parent c1468e8ae4
commit ad10e9a062
No known key found for this signature in database
GPG key ID: 91F477359C5B7AD3
163 changed files with 104 additions and 135 deletions

35
pkg/chart/jet.go Normal file
View file

@ -0,0 +1,35 @@
package chart
import (
"github.com/d-Rickyy-b/go-chart-x/v2/pkg/drawing"
)
// Jet is a color map provider based on matlab's jet color map.
func Jet(v, vmin, vmax float64) drawing.Color {
c := drawing.Color{R: 0xff, G: 0xff, B: 0xff, A: 0xff} // white
var dv float64
if v < vmin {
v = vmin
}
if v > vmax {
v = vmax
}
dv = vmax - vmin
if v < (vmin + 0.25*dv) {
c.R = 0
c.G = drawing.ColorChannelFromFloat(4 * (v - vmin) / dv)
} else if v < (vmin + 0.5*dv) {
c.R = 0
c.B = drawing.ColorChannelFromFloat(1 + 4*(vmin+0.25*dv-v)/dv)
} else if v < (vmin + 0.75*dv) {
c.R = drawing.ColorChannelFromFloat(4 * (v - vmin - 0.5*dv) / dv)
c.B = 0
} else {
c.G = drawing.ColorChannelFromFloat(1 + 4*(vmin+0.75*dv-v)/dv)
c.B = 0
}
return c
}