render.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/gookit/color"
  5. )
  6. func render (route []Route) {
  7. var r, g, b uint8
  8. col := "fcfcfc"
  9. fmt.Sscanf("ff7e56", "%2x%2x%2x", &r, &g, &b)
  10. b1 := color.RGB(uint8(r), uint8(g), uint8(b)).Sprint("早")
  11. fmt.Sscanf("60bddb", "%2x%2x%2x", &r, &g, &b)
  12. b2 := color.RGB(uint8(r), uint8(g), uint8(b)).Sprint("楽")
  13. fmt.Sscanf("fab60a", "%2x%2x%2x", &r, &g, &b)
  14. b3 := color.RGB(uint8(r), uint8(g), uint8(b)).Sprint("安")
  15. fmt.Sscanf(col, "%2x%2x%2x", &r, &g, &b)
  16. c := color.RGB(uint8(r), uint8(g), uint8(b)).Sprint("")
  17. for key, value := range route {
  18. color.Style{color.FgBlack, color.BgMagenta, color.OpBold}.Println("# ルート" + fmt.Sprintf("%d", key+1))
  19. badges := ""
  20. for _, badge := range value.Badges {
  21. if badge == 1 {
  22. badges += "〈" + b1 + "〉"
  23. }
  24. if badge == 2 {
  25. badges += "〈" + b2 + "〉"
  26. }
  27. if badge == 3 {
  28. badges += "〈" + b3 + "〉"
  29. }
  30. }
  31. fmt.Println(value.Time + " (" + value.Duration + "), " + value.Fare + ", 乗換数:" + value.TransitCunt + " " + badges)
  32. for k, v := range value.Stations {
  33. fmt.Println(v.Time + " " + v.Name)
  34. for i, fare := range v.Fares {
  35. if k == i {
  36. col = fare.Color
  37. fmt.Sscanf(col, "%2x%2x%2x", &r, &g, &b)
  38. text := fare.Train
  39. if fare.Platform != "" { text += "\n" + fare.Platform }
  40. c = color.RGB(uint8(r), uint8(g), uint8(b)).Sprint(text)
  41. fmt.Println(c)
  42. }
  43. }
  44. }
  45. fmt.Println("")
  46. }
  47. }