本文整理汇总了C#中ColorGradient.Lerp方法的典型用法代码示例。如果您正苦于以下问题:C# ColorGradient.Lerp方法的具体用法?C# ColorGradient.Lerp怎么用?C# ColorGradient.Lerp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColorGradient
的用法示例。
在下文中一共展示了ColorGradient.Lerp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compose
public override void Compose()
{
if (this.IsDirty)
{
this.Fill(Color.White, Color.Black, 0, null);
_positions = Width;
ColorGradient gradient = new ColorGradient(Color.Red, Color.Yellow, Color.Green, Color.Turquoise, Color.Blue, Color.Purple, Color.Red);
for (int x = 0; x < Width; x++)
{
this[x, 0].GlyphIndex = 219;
this[x, 0].Foreground = gradient.Lerp((float)x / (float)(Width - 1));
}
this[_selectedPosition, 1].GlyphIndex = 30;
this[_selectedPosition, 1].Foreground = Color.LightGray;//this[_selectedPosition, 0].Foreground;
// Build an array of all the colors
Color[] colors = new Color[Width];
for (int x = 0; x < Width; x++)
colors[x] = this[x, 0].Foreground;
List<int> colorIndexesFinished = new List<int>(Width);
foreach (var stop in gradient.Stops)
{
ColorMine.ColorSpaces.Rgb rgbColorStop = new ColorMine.ColorSpaces.Rgb() { R = stop.Color.R, G = stop.Color.G, B = stop.Color.B };
Tuple<Color, double, int>[] colorWeights = new Tuple<Color, double, int>[Width];
// Create a color weight for every cell compared to the color stop
for (int x = 0; x < Width; x++)
{
if (!colorIndexesFinished.Contains(x))
{
ColorMine.ColorSpaces.Rgb rgbColor = new ColorMine.ColorSpaces.Rgb() { R = colors[x].R, G = colors[x].G, B = colors[x].B };
ColorMine.ColorSpaces.Cmy cmyColor = rgbColor.To<ColorMine.ColorSpaces.Cmy>();
colorWeights[x] = new Tuple<Color, double, int>(colors[x], rgbColorStop.Compare(cmyColor, new ColorMine.ColorSpaces.Comparisons.Cie1976Comparison()), x);
}
else
colorWeights[x] = new Tuple<Color, double, int>(colors[x], 10000, x);
}
var foundColor = colorWeights.OrderBy(t => t.Item2).First();
this[foundColor.Item3, 0].Foreground = stop.Color;
colorIndexesFinished.Add(foundColor.Item3);
}
this.IsDirty = false;
}
}