private static GradientStopCollection fromInterpolation(GradientStopCollection min, double p, GradientStopCollection max) { if (min.Count < max.Count) { GradientStopCollection t = min; min = max; max = t; p = 1 - p; } GradientStopCollection ret = new GradientStopCollection(); for (int i = 0; i < min.Count; ++i) { ret.Add(new GradientStop() { Color = ColorTool.FromARGBInterpolation(min[i].Color, p, max[i].Color), Offset = min[i].Offset * (1.0 - p) + max[i].Offset * p }); } for (int i = min.Count; i < max.Count; ++i) { ret.Add(new GradientStop() { Color = ColorTool.FromARGBInterpolation(min[min.Count - 1].Color, p, max[i].Color), Offset = min[min.Count - 1].Offset * (1.0 - p) + max[i].Offset * p }); } return(ret); }
private static Brush fromInterpolation(SolidColorBrush min, double p, SolidColorBrush max) { return(new SolidColorBrush(ColorTool.FromARGBInterpolation(min.Color, p, max.Color)) { Opacity = min.Opacity * (1.0 - p) + max.Opacity * p }); }
private static GradientStopCollection fromInterpolation(Color min, double p, GradientStopCollection max) { GradientStopCollection ret = new GradientStopCollection(); double[] ahsvMin = ColorTool.AHSV(min); for (int i = 0; i < max.Count; ++i) { double[] ahsv = ColorTool.FromAHSVInterpolation(ahsvMin, p, ColorTool.AHSV(max[i].Color)); Color color = ColorTool.FromAHSV(ahsv[0], ahsv[1], ahsv[2], ahsv[3]); color = ColorTool.FromARGBInterpolation(min, p, max[i].Color); ret.Add(new GradientStop() { Color = color, Offset = max[i].Offset }); } return(ret); }