Exemple #1
0
void SVGAnimatedColorAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated)
{
    ASSERT(m_animationElement);
    ASSERT(m_contextElement);

    StyleColor fromStyleColor = m_animationElement->animationMode() == ToAnimation ? animated->color() : from->color();
    StyleColor toStyleColor = to->color();
    StyleColor toAtEndOfDurationStyleColor = toAtEndOfDuration->color();
    StyleColor& animatedStyleColor = animated->color();

    // Apply CSS inheritance rules.
    m_animationElement->adjustForInheritance<StyleColor>(parseColorFromString, m_animationElement->fromPropertyValueType(), fromStyleColor, m_contextElement);
    m_animationElement->adjustForInheritance<StyleColor>(parseColorFromString, m_animationElement->toPropertyValueType(), toStyleColor, m_contextElement);

    // Apply currentColor rules.
    Color fallbackColor = fallbackColorForCurrentColor(m_contextElement);
    Color fromColor = fromStyleColor.resolve(fallbackColor);
    Color toColor = toStyleColor.resolve(fallbackColor);
    Color toAtEndOfDurationColor = toAtEndOfDurationStyleColor.resolve(fallbackColor);
    Color animatedColor = animatedStyleColor.resolve(fallbackColor);

    float animatedRed = animatedColor.red();
    m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.red(), toColor.red(), toAtEndOfDurationColor.red(), animatedRed);

    float animatedGreen = animatedColor.green();
    m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.green(), toColor.green(), toAtEndOfDurationColor.green(), animatedGreen);

    float animatedBlue = animatedColor.blue();
    m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.blue(), toColor.blue(), toAtEndOfDurationColor.blue(), animatedBlue);

    float animatedAlpha = animatedColor.alpha();
    m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.alpha(), toColor.alpha(), toAtEndOfDurationColor.alpha(), animatedAlpha);

    animatedStyleColor = StyleColor(makeRGBA(roundf(animatedRed), roundf(animatedGreen), roundf(animatedBlue), roundf(animatedAlpha)));
}
Exemple #2
0
void SVGColorProperty::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromValue, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement)
{
    StyleColor fromStyleColor = toSVGColorProperty(fromValue)->m_styleColor;
    StyleColor toStyleColor = toSVGColorProperty(toValue)->m_styleColor;
    StyleColor toAtEndOfDurationStyleColor = toSVGColorProperty(toAtEndOfDurationValue)->m_styleColor;

    // Apply currentColor rules.
    ASSERT(contextElement);
    Color fallbackColor = fallbackColorForCurrentColor(contextElement);
    Color fromColor = fromStyleColor.resolve(fallbackColor);
    Color toColor = toStyleColor.resolve(fallbackColor);
    Color toAtEndOfDurationColor = toAtEndOfDurationStyleColor.resolve(fallbackColor);
    Color animatedColor = m_styleColor.resolve(fallbackColor);

    ASSERT(animationElement);
    float animatedRed = animatedColor.red();
    animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.red(), toColor.red(), toAtEndOfDurationColor.red(), animatedRed);

    float animatedGreen = animatedColor.green();
    animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.green(), toColor.green(), toAtEndOfDurationColor.green(), animatedGreen);

    float animatedBlue = animatedColor.blue();
    animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.blue(), toColor.blue(), toAtEndOfDurationColor.blue(), animatedBlue);

    float animatedAlpha = animatedColor.alpha();
    animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.alpha(), toColor.alpha(), toAtEndOfDurationColor.alpha(), animatedAlpha);

    m_styleColor = StyleColor(makeRGBA(roundf(animatedRed), roundf(animatedGreen), roundf(animatedBlue), roundf(animatedAlpha)));
}
Exemple #3
0
void SVGAnimatedColorAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnimatedType* to)
{
    ASSERT(from->type() == AnimatedColor);
    ASSERT(from->type() == to->type());
    Color fallbackColor = fallbackColorForCurrentColor(m_contextElement);
    Color fromColor = from->color().resolve(fallbackColor);
    Color toColor = to->color().resolve(fallbackColor);
    to->color() = ColorDistance::addColors(fromColor, toColor);
}
Exemple #4
0
float SVGColorProperty::calculateDistance(PassRefPtr<NewSVGPropertyBase> toValue, SVGElement* contextElement)
{
    ASSERT(contextElement);
    Color fallbackColor = fallbackColorForCurrentColor(contextElement);

    Color fromColor = m_styleColor.resolve(fallbackColor);
    Color toColor = toSVGColorProperty(toValue)->m_styleColor.resolve(fallbackColor);
    return ColorDistance::distance(fromColor, toColor);
}
Exemple #5
0
void SVGColorProperty::add(PassRefPtr<NewSVGPropertyBase> other, SVGElement* contextElement)
{
    ASSERT(contextElement);

    Color fallbackColor = fallbackColorForCurrentColor(contextElement);
    Color fromColor = toSVGColorProperty(other)->m_styleColor.resolve(fallbackColor);
    Color toColor = m_styleColor.resolve(fallbackColor);
    m_styleColor = StyleColor(ColorDistance::addColors(fromColor, toColor));
}