当前位置: 首页>>代码示例>>C#>>正文


C# Color.ToHSV方法代码示例

本文整理汇总了C#中UnityEngine.Color.ToHSV方法的典型用法代码示例。如果您正苦于以下问题:C# Color.ToHSV方法的具体用法?C# Color.ToHSV怎么用?C# Color.ToHSV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Color的用法示例。


在下文中一共展示了Color.ToHSV方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeGradientHSV

 /// <summary>
 /// Make a gradient between two colors using HSV (Returns a list of colors blended from startColor to endColor).
 /// </summary>
 /// <returns>A list of colors blended from startColor to endColor.</returns>
 /// <param name="startColor">Start color.</param>
 /// <param name="endColor">End color.</param>
 /// <param name="blendColors>Number of blended colors in the middle (returned list's length will be this value plus two).</param>
 public static List<Color> MakeGradientHSV(Color startColor, Color endColor, int blendColors)
 {
     List<Color> gradient = new List<Color>();
     float startHue = startColor.ToHSV().h;
     float endHue = endColor.ToHSV().h;
     float startSat = startColor.ToHSV().s;
     float endSat = endColor.ToHSV().s;
     float startVal = startColor.ToHSV().v;
     float endVal = endColor.ToHSV().v;
     float degreesPerStep = (endHue - startHue);
     if (degreesPerStep > 180f) {
         degreesPerStep = degreesPerStep - 360f;
     }
     if (degreesPerStep < -180f) {
         degreesPerStep = degreesPerStep + 360f;
     }
     float saturationPerStep = (endSat - startSat);
     float valuePerStep = (endVal - startVal);
     degreesPerStep /= (float)(blendColors + 1);
     saturationPerStep /= (float)(blendColors + 1);
     valuePerStep /= (float)(blendColors + 1);
     gradient.Add(startColor);
     ColorHSV colorHSV = startColor.ToHSV();
     for (int i = 0; i < blendColors; i++) {
         colorHSV.ShiftHue(degreesPerStep);
         colorHSV.s += saturationPerStep;
         colorHSV.v += valuePerStep;
         gradient.Add(colorHSV.ToColor());
     }
     gradient.Add(endColor);
     return gradient;
 }
开发者ID:DomCristaldi,项目名称:Coda,代码行数:39,代码来源:JBirdColorLibrary.cs

示例2: Rainbowify

 /// <summary>
 /// Make a rainbow from the start color, shifting the hue until it reaches the end hue. (Returns a list of Colors).
 /// </summary>
 /// <param name="startColor">Start color.</param>
 /// <param name="endColor">Hue to stop shifting at (will only use the hue of this color, not value or saturation).</param>
 /// <param name="length">Desired length of the list.</param>
 public static List<Color> Rainbowify(Color startColor, Color endColor, int length)
 {
     List<Color> rainbow = new List<Color>();
     float startHue = startColor.ToHSV().h;
     float endHue = endColor.ToHSV().h;
     if (endHue < startHue) {
         endHue += 360f;
     }
     float degreesPerStep = (endHue - startHue);
     degreesPerStep /= (float)length - 1;
     rainbow.Add(startColor);
     ColorHSV colorHSV = startColor.ToHSV();
     for (int i = 0; i < length - 1; i++) {
         colorHSV.ShiftHue(degreesPerStep);
         rainbow.Add(colorHSV.ToColor());
     }
     return rainbow;
 }
开发者ID:DomCristaldi,项目名称:Coda,代码行数:24,代码来源:JBirdColorLibrary.cs


注:本文中的UnityEngine.Color.ToHSV方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。