MCPcopy Create free account
hub / github.com/pterm/pterm / getColor

Function getColor

heatmap_printer.go:657–671  ·  view source on GitHub ↗
(minStep float32, maxStep float32, current float32, colors ...Color)

Source from the content-addressed store, hash-verified

655}
656
657func getColor(minStep float32, maxStep float32, current float32, colors ...Color) Color {
658 // split the range into equal parts
659 // and assign a color to each part
660 // the last color is assigned to the max value
661 // and the first color to the min value
662 // the rest of the colors are assigned to the
663 // middle values
664 step := (maxStep - minStep) / float32(len(colors))
665 for i := range colors {
666 if current >= minStep+float32(i)*step && current < minStep+float32(i+1)*step {
667 return colors[i]
668 }
669 }
670 return colors[len(colors)-1]
671}
672
673// Render prints the HeatmapPrinter to the terminal.
674func (p HeatmapPrinter) Render() error {

Callers 1

renderDataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…