public Color GetColor(double t) { Verify.AssertIsFinite(t); Verify.IsTrue(0 <= t && t <= 1); if (t <= 0) { return(colors[0]); } else if (t >= 1) { return(colors[colors.Count - 1]); } else { int i = 0; while (points[i] < t) { i++; } double ratio = (points[i] - t) / (points[i] - points[i - 1]); Verify.IsTrue(0 <= ratio && ratio <= 1); Color c0 = colors[i - 1]; Color c1 = colors[i]; Color res = Color.FromRgb( (byte)(c0.R * ratio + c1.R * (1 - ratio)), (byte)(c0.G * ratio + c1.G * (1 - ratio)), (byte)(c0.B * ratio + c1.B * (1 - ratio))); // Increasing saturation and brightness if (increaseBrightness) { HsbColor hsb = res.ToHsbColor(); //hsb.Saturation = 0.5 * (1 + hsb.Saturation); hsb.Brightness = 0.5 * (1 + hsb.Brightness); return(hsb.ToArgbColor()); } else { return(res); } } }