Tecnologías XML / SVG / Utilizar animaciones / Formas de realizar animaciones / Ajustar colores con animateColor

(Extracto de «Das Einsteigerseminar SVG — Webgrafiken mit XML» de Helma Spona)

Como mostró el primer ejemplo del capítulo, la etiqueta <animateColor> anima el color de relleno o borde de un elemento. Solo tiene los atributos universales de animación, pero hay particularidades. Asigne colores a los atributos from, by y to, y la lista values también debe contener colores separados por punto y coma.

El atributo values indica los colores mostrados sucesivamente. Con colores inicial y final definidos por from y to, a diferencia de una lista values, no puede elegir los valores intermedios. El siguiente ejemplo lo muestra cambiando el relleno o contorno del texto con distintas animaciones.

La primera animación pasa de azul a rojo, con calcMode="discrete" que muestra el resultado solo al terminar. La segunda también pasa de azul a rojo, pero omite calcMode, por lo que se ven las transiciones.

La tercera animación utiliza el atributo values para definir los colores y el atributo keyTimes para determinar tras cuántos segundos ocurre. Las dos últimas animaciones afectan al último texto y cambian los colores de relleno y contorno en sentidos opuestos.

Nota:
En lugar de nombres de colores, también puede utilizar la instrucción rgb correspondiente.

<defs>
  <animateColor xlink:href="#text1" dur="6s" from="blue" to="red" attributeName="fill" calcMode="discrete" fill="freeze"/>
  <animateColor xlink:href="#text2" dur="6s" from="blue" to="red" attributeName="fill" fill="freeze"/>
  <animateColor xlink:href="#text3" dur="6s" begin="4s" values="blue;red;green;blue;white;yellow;red" keyTimes="0;1;1.5;2;3;3.5;4" attributeName="fill" fill="freeze"/>
  <animateColor xlink:href="#text4" dur="6s" begin="4s" from="blue" to="red" attributeName="fill" fill="freeze"/>
  <animateColor xlink:href="#text4" dur="6s" begin="4s" from="red" to="blue" attributeName="stroke" fill="freeze"/>
</defs>
<text x="20" y="40" id="text1" style="font-family:'Arial Black';font-size:40px;fill:blue;stroke:red">SVG</text>
<text x="20" y="100" id="text2" style="font-family:'Arial Black';font-size:40px;fill:blue;stroke:red">SVG</text>
<text x="20" y="160" id="text3" style="font-family:'Arial Black';font-size:40px;fill:blue;stroke:red">SVG</text>
<text x="20" y="220" id="text4" style="font-family:'Arial Black';font-size:40px;fill:blue;stroke:red">SVG</text>

   

<< atrás

siguiente >>

 

 

 

volver arriba