mirror of
https://github.com/Dvorinka/Devour.git
synced 2026-06-03 20:13:03 +00:00
137 lines
3.5 KiB
Go
137 lines
3.5 KiB
Go
package scorecard
|
|
|
|
import "image/color"
|
|
|
|
// Scale for retina/high-DPI rendering
|
|
const Scale = 2
|
|
|
|
// Theme colors for the scorecard badge - warm earth-tone palette
|
|
var (
|
|
// BG is the main background (warm cream)
|
|
BG = color.RGBA{R: 247, G: 240, B: 228, A: 255}
|
|
// BGScore is the score panel background
|
|
BGScore = color.RGBA{R: 240, G: 232, B: 217, A: 255}
|
|
// BGTable is the table background
|
|
BGTable = color.RGBA{R: 240, G: 233, B: 220, A: 255}
|
|
// BGRowAlt is the alternate row background
|
|
BGRowAlt = color.RGBA{R: 234, G: 226, B: 212, A: 255}
|
|
// TEXT is the main text color (dark brown)
|
|
TEXT = color.RGBA{R: 58, G: 48, B: 38, A: 255}
|
|
// DIM is the dimmed text color (warm gray)
|
|
DIM = color.RGBA{R: 138, G: 122, B: 102, A: 255}
|
|
// BORDER is the inner border color (warm tan)
|
|
BORDER = color.RGBA{R: 192, G: 176, B: 152, A: 255}
|
|
// ACCENT is the accent color (warm brown)
|
|
ACCENT = color.RGBA{R: 148, G: 112, B: 82, A: 255}
|
|
// FRAME is the outer frame color (warm tan)
|
|
FRAME = color.RGBA{R: 172, G: 152, B: 126, A: 255}
|
|
)
|
|
|
|
// Score grade colors - gradient from sage to rose
|
|
var (
|
|
// GradeA is for scores 90-100% (deep sage green)
|
|
GradeA = color.RGBA{R: 68, G: 120, B: 68, A: 255}
|
|
// GradeB is for scores 70-89% (olive green)
|
|
GradeB = color.RGBA{R: 120, G: 140, B: 72, A: 255}
|
|
// GradeC is for scores 50-69% (yellow-green)
|
|
GradeC = color.RGBA{R: 145, G: 155, B: 80, A: 255}
|
|
// GradeD is for scores 30-49% (mustard)
|
|
GradeD = color.RGBA{R: 180, G: 150, B: 70, A: 255}
|
|
// GradeF is for scores 0-29% (dusty rose)
|
|
GradeF = color.RGBA{R: 170, G: 110, B: 90, A: 255}
|
|
)
|
|
|
|
// Muted score colors for strict column (pastel orange/peach shades)
|
|
var (
|
|
// GradeAMuted is muted version of GradeA
|
|
GradeAMuted = color.RGBA{R: 195, G: 160, B: 115, A: 255} // light sandy peach
|
|
// GradeBMuted is muted version of GradeB
|
|
GradeBMuted = color.RGBA{R: 200, G: 148, B: 100, A: 255} // warm apricot
|
|
// GradeCMuted is muted version of GradeC
|
|
GradeCMuted = color.RGBA{R: 195, G: 125, B: 95, A: 255} // soft coral
|
|
// GradeDMuted is muted version of GradeD
|
|
GradeDMuted = color.RGBA{R: 190, G: 130, B: 100, A: 255}
|
|
// GradeFMuted is muted version of GradeF
|
|
GradeFMuted = color.RGBA{R: 185, G: 120, B: 100, A: 255}
|
|
)
|
|
|
|
// Severity colors for findings
|
|
var (
|
|
SeverityT1Color = color.RGBA{R: 100, G: 180, B: 255, A: 255}
|
|
SeverityT2Color = color.RGBA{R: 255, G: 200, B: 100, A: 255}
|
|
SeverityT3Color = color.RGBA{R: 255, G: 140, B: 80, A: 255}
|
|
SeverityT4Color = color.RGBA{R: 255, G: 80, B: 80, A: 255}
|
|
)
|
|
|
|
func GetGradeColor(grade string) color.RGBA {
|
|
switch grade {
|
|
case "A":
|
|
return GradeA
|
|
case "B":
|
|
return GradeB
|
|
case "C":
|
|
return GradeC
|
|
case "D":
|
|
return GradeD
|
|
default:
|
|
return GradeF
|
|
}
|
|
}
|
|
|
|
func GetGradeColorMuted(grade string) color.RGBA {
|
|
switch grade {
|
|
case "A":
|
|
return GradeAMuted
|
|
case "B":
|
|
return GradeBMuted
|
|
case "C":
|
|
return GradeCMuted
|
|
case "D":
|
|
return GradeDMuted
|
|
default:
|
|
return GradeFMuted
|
|
}
|
|
}
|
|
|
|
func GetScoreGrade(score int) string {
|
|
switch {
|
|
case score >= 90:
|
|
return "A"
|
|
case score >= 70:
|
|
return "B"
|
|
case score >= 50:
|
|
return "C"
|
|
case score >= 30:
|
|
return "D"
|
|
default:
|
|
return "F"
|
|
}
|
|
}
|
|
|
|
func GetScoreColor(score int) color.RGBA {
|
|
return GetGradeColor(GetScoreGrade(score))
|
|
}
|
|
|
|
func GetScoreColorMuted(score int) color.RGBA {
|
|
return GetGradeColorMuted(GetScoreGrade(score))
|
|
}
|
|
|
|
func GetSeverityColor(severity int) color.RGBA {
|
|
switch severity {
|
|
case 1:
|
|
return SeverityT1Color
|
|
case 2:
|
|
return SeverityT2Color
|
|
case 3:
|
|
return SeverityT3Color
|
|
case 4:
|
|
return SeverityT4Color
|
|
default:
|
|
return DIM
|
|
}
|
|
}
|
|
|
|
func ScaleValue(v int) int {
|
|
return v * Scale
|
|
}
|