11package main
22
33import (
4- "math"
54 "log"
5+ "math"
66)
77
88type colorPoint struct {
@@ -19,9 +19,9 @@ func makeColorPalette(controlColors []colorPoint, numColors int) []colorPoint {
1919 //If first control color is not at 0 then copy color for range
2020 lastIndexFilled := 0
2121 outColors := make ([]colorPoint , numColors )
22- outColors [0 ].red = math .Round (controlColors [0 ].red * 255.0 / 100.0 )
23- outColors [0 ].blue = math .Round (controlColors [0 ].blue * 255.0 / 100.0 )
24- outColors [0 ].green = math .Round (controlColors [0 ].green * 255.0 / 100.0 )
22+ outColors [0 ].red = math .Round (controlColors [0 ].red * 255.0 / 100.0 )
23+ outColors [0 ].blue = math .Round (controlColors [0 ].blue * 255.0 / 100.0 )
24+ outColors [0 ].green = math .Round (controlColors [0 ].green * 255.0 / 100.0 )
2525 for i := 1 ; i < len (controlColors ); i ++ {
2626 //possDiff:=controlColors[i].position-lastPoint.position
2727 redDiff := (float64 (controlColors [i ].red ) - float64 (lastPoint .red )) * 255.0 / 100
@@ -30,7 +30,7 @@ func makeColorPalette(controlColors []colorPoint, numColors int) []colorPoint {
3030 startRange := lastIndexFilled + 1
3131 endRange := int (math .Round (float64 (controlColors [i ].position ) * float64 (colorsPerPosition )))
3232 for j := startRange ; j < endRange ; j ++ {
33-
33+
3434 percentRange := (float64 (j + 1 ) - float64 (startRange )) / float64 ((endRange - startRange ))
3535 outColors [j ].red = (math .Round (percentRange * redDiff + float64 (lastPoint .red )* 255.0 / 100 ))
3636 outColors [j ].green = (math .Round (percentRange * greenDiff + float64 (lastPoint .green )* 255.0 / 100 ))
@@ -81,34 +81,34 @@ func getColorConrolPoints(colorMap string) []colorPoint {
8181 outColors [6 ] = colorPoint {100 , 95 , 95 , 95 }
8282 case "calewhite" :
8383 outColors = make ([]colorPoint , 7 )
84- outColors [0 ] = colorPoint { 0 , 100 ,100 ,100 }
85- outColors [1 ] = colorPoint { 16.666 ,0 , 0 , 100 }
86- outColors [2 ] = colorPoint { 33.333 ,0 , 100 ,100 }
87- outColors [3 ] = colorPoint { 50 ,0 , 100 ,0 }
88- outColors [4 ] = colorPoint { 66.666 ,100 ,100 ,0 }
89- outColors [5 ] = colorPoint { 83.333 ,100 ,0 , 0 }
90- outColors [6 ] = colorPoint { 100 ,100 ,0 , 100 }
84+ outColors [0 ] = colorPoint {0 , 100 , 100 , 100 }
85+ outColors [1 ] = colorPoint {16.666 , 0 , 0 , 100 }
86+ outColors [2 ] = colorPoint {33.333 , 0 , 100 , 100 }
87+ outColors [3 ] = colorPoint {50 , 0 , 100 , 0 }
88+ outColors [4 ] = colorPoint {66.666 , 100 , 100 , 0 }
89+ outColors [5 ] = colorPoint {83.333 , 100 , 0 , 0 }
90+ outColors [6 ] = colorPoint {100 , 100 , 0 , 100 }
9191 case "HotDesat" :
9292 outColors = make ([]colorPoint , 8 )
93- outColors [0 ] = colorPoint { 0 , 27.84 ,27.84 ,85.88 }
94- outColors [1 ] = colorPoint { 14.2857 ,0 , 0 , 35.69 }
95- outColors [2 ] = colorPoint { 28.571 ,0 , 100 ,100 }
96- outColors [3 ] = colorPoint { 42.857 ,0 , 49.8 ,0 }
97- outColors [4 ] = colorPoint { 57.14286 ,100 ,100 ,0 }
98- outColors [5 ] = colorPoint { 71.42857 ,100 ,37.65 ,0 }
99- outColors [6 ] = colorPoint { 85.7143 ,41.96 ,0 , 0 }
100- outColors [7 ] = colorPoint { 100 ,87.84 ,29.8 ,29.8 }
93+ outColors [0 ] = colorPoint {0 , 27.84 , 27.84 , 85.88 }
94+ outColors [1 ] = colorPoint {14.2857 , 0 , 0 , 35.69 }
95+ outColors [2 ] = colorPoint {28.571 , 0 , 100 , 100 }
96+ outColors [3 ] = colorPoint {42.857 , 0 , 49.8 , 0 }
97+ outColors [4 ] = colorPoint {57.14286 , 100 , 100 , 0 }
98+ outColors [5 ] = colorPoint {71.42857 , 100 , 37.65 , 0 }
99+ outColors [6 ] = colorPoint {85.7143 , 41.96 , 0 , 0 }
100+ outColors [7 ] = colorPoint {100 , 87.84 , 29.8 , 29.8 }
101101 case "Sunset" :
102102 outColors = make ([]colorPoint , 7 )
103- outColors [0 ] = colorPoint { 0 , 10 ,0 , 23 }
104- outColors [1 ] = colorPoint { 18 ,34 ,0 , 60 }
105- outColors [2 ] = colorPoint { 36 ,58 ,20 ,47 }
106- outColors [3 ] = colorPoint { 55 ,74 ,20 ,28 }
107- outColors [4 ] = colorPoint { 72 ,90 ,43 ,0 }
108- outColors [5 ] = colorPoint { 87 ,100 ,72 ,0 }
109- outColors [6 ] = colorPoint { 100 ,100 ,100 ,76 }
103+ outColors [0 ] = colorPoint {0 , 10 , 0 , 23 }
104+ outColors [1 ] = colorPoint {18 , 34 , 0 , 60 }
105+ outColors [2 ] = colorPoint {36 , 58 , 20 , 47 }
106+ outColors [3 ] = colorPoint {55 , 74 , 20 , 28 }
107+ outColors [4 ] = colorPoint {72 , 90 , 43 , 0 }
108+ outColors [5 ] = colorPoint {87 , 100 , 72 , 0 }
109+ outColors [6 ] = colorPoint {100 , 100 , 100 , 76 }
110110 default :
111- log .Println ("Unknown Colormap" ,colorMap , "using default RampColormap" )
111+ log .Println ("Unknown Colormap" , colorMap , "using default RampColormap" )
112112 outColors = make ([]colorPoint , 7 )
113113 outColors [0 ] = colorPoint {0 , 0 , 0 , 15 }
114114 outColors [1 ] = colorPoint {10 , 0 , 0 , 50 }
0 commit comments