本文整理汇总了C#中ColorGradient.GetColorsInGradient方法的典型用法代码示例。如果您正苦于以下问题:C# ColorGradient.GetColorsInGradient方法的具体用法?C# ColorGradient.GetColorsInGradient怎么用?C# ColorGradient.GetColorsInGradient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColorGradient
的用法示例。
在下文中一共展示了ColorGradient.GetColorsInGradient方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderNode
// renders the given node to the internal ElementData dictionary. If the given node is
// not a element, will recursively descend until we render its elements.
public static EffectIntents RenderNode(ElementNode node, Curve levelCurve, ColorGradient colorGradient, TimeSpan duration, bool isDiscrete, bool allowZeroIntensity = false)
{
//Collect all the points first.
double[] allPointsTimeOrdered = _GetAllSignificantDataPoints(levelCurve, colorGradient).ToArray();
var elementData = new EffectIntents();
foreach (ElementNode elementNode in node.GetLeafEnumerator())
{
// this is probably always going to be a single element for the given node, as
// we have iterated down to leaf nodes in RenderNode() above. May as well do
// it this way, though, in case something changes in future.
if (elementNode == null || elementNode.Element == null)
continue;
//ElementColorType colorType = ColorModule.getColorTypeForElementNode(elementNode);
if (isDiscrete && IsElementDiscrete(node))
{
IEnumerable<Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false)
.Intersect(colorGradient.GetColorsInGradient());
foreach (Color color in colors)
{
AddIntentsToElement(elementNode.Element, allPointsTimeOrdered, levelCurve, colorGradient, duration, elementData, allowZeroIntensity, color);
}
}
else
{
AddIntentsToElement(elementNode.Element, allPointsTimeOrdered, levelCurve, colorGradient, duration, elementData, allowZeroIntensity);
}
}
return elementData;
}
示例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;
}