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


C# ColorGradient.GetProportionOfColorAt方法代码示例

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


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

示例1: AddIntentsToElement

        private static void AddIntentsToElement(Element element, double[] allPointsTimeOrdered, Curve levelCurve, ColorGradient colorGradient, TimeSpan duration, EffectIntents elementData, bool allowZeroIntensity, Color? color = null)
        {
            if (element != null)
            {
                double lastPosition = allPointsTimeOrdered[0];
                TimeSpan lastEnd = TimeSpan.Zero;
                for (var i = 1; i < allPointsTimeOrdered.Length; i++)
                {
                    double position = allPointsTimeOrdered[i];
                    TimeSpan startTime = lastEnd;
                    TimeSpan timeSpan = TimeSpan.FromMilliseconds(duration.TotalMilliseconds * (position - lastPosition));

                    if (color == null)
                    {
                        var startColor = colorGradient.GetColorAt(lastPosition);
                        var endColor = colorGradient.GetColorAt(position);
                        var startIntensity = levelCurve.GetValue(lastPosition * 100) / 100;
                        var endIntensity = levelCurve.GetValue(position * 100) / 100;

                        if (allowZeroIntensity || !(startIntensity.Equals(0) && endIntensity.Equals(0)))
                        {
                            IIntent intent = IntentBuilder.CreateIntent(startColor, endColor, startIntensity, endIntensity, timeSpan);
                            elementData.AddIntentForElement(element.Id, intent, startTime);
                        }
                    }
                    else
                    {
                        var startIntensity = (colorGradient.GetProportionOfColorAt(lastPosition, (Color)color) * levelCurve.GetValue(lastPosition * 100) / 100);
                        var endIntensity = (colorGradient.GetProportionOfColorAt(position, (Color)color) * levelCurve.GetValue(position * 100) / 100);

                        if (allowZeroIntensity || !(startIntensity.Equals(0) && endIntensity.Equals(0)))
                        {
                            IIntent intent = IntentBuilder.CreateDiscreteIntent((Color)color, startIntensity, endIntensity, timeSpan);
                            elementData.AddIntentForElement(element.Id, intent, startTime);
                        }

                    }

                    lastPosition = position;
                    lastEnd = startTime + timeSpan;
                }
            }
        }
开发者ID:jaredb7,项目名称:vixen,代码行数:43,代码来源:PulseRenderer.cs

示例2: GenerateEffectIntents

        /// <summary>
        /// Convienience method to generate intents that knows how to deal with discrete colors.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="gradient"></param>
        /// <param name="level"></param>
        /// <param name="startPos"></param>
        /// <param name="endPos"></param>
        /// <param name="duration"></param>
        /// <param name="startTime"></param>
        /// <param name="isDiscrete"></param>
        /// <returns></returns>
        protected EffectIntents GenerateEffectIntents(ElementNode node, ColorGradient gradient, Curve level, double startPos, double endPos,
            TimeSpan duration, TimeSpan startTime, bool isDiscrete)
        {
            EffectIntents result = new EffectIntents();
            if (isDiscrete)
            {
                IEnumerable<Color> colors = ColorModule.getValidColorsForElementNode(node, false)
                         .Intersect(gradient.GetColorsInGradient());
                foreach (Color color in colors)
                {
                    double proportion = gradient.GetProportionOfColorAt(startPos, color);
                    var startIntensity = (level.GetValue(startPos * 100) / 100) * proportion;
                    proportion = gradient.GetProportionOfColorAt(endPos, color);
                    var endIntensity = (level.GetValue(endPos * 100) / 100) * proportion;
                    if (startIntensity > 0 && endIntensity > 0)
                    {
                        var intent = CreateDiscreteIntent(color, startIntensity, endIntensity, duration);
                        result.AddIntentForElement(node.Element.Id, intent, startTime);
                    }
                }
            }
            else
            {
                var startIntensity = level.GetValue(startPos * 100) / 100;
                var endIntensity = level.GetValue(endPos * 100) / 100;
                if (startIntensity > 0 && endIntensity > 0)
                {
                    var intent = CreateIntent(gradient.GetColorAt(startPos), gradient.GetColorAt(endPos), startIntensity, endIntensity, duration);
                    result.AddIntentForElement(node.Element.Id, intent, startTime);
                }
            }

            return result;
        }
开发者ID:jaredb7,项目名称:vixen,代码行数:46,代码来源:AudioPluginBase.cs


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