html - Is it possible to distort SVG text dynamically? -


is possible distort svg text dynamically?

for example, apply filters shifting parameters based on temporal data?

thanks.

yes, it's possible:

let step = () => {    let blur = document.queryselector('svg > #blur > fegaussianblur');    let value = parsefloat(blur.getattribute('stddeviation'));    blur.setattribute('stddeviation', value * 1.05);        requestanimationframe(step);  };    requestanimationframe(step);
<svg width="250" height="100"      xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">      <filter id="blur">      <fegaussianblur in="sourcegraphic" stddeviation="1"/>    </filter>      <text x="15" y="50" font-size="35" filter="url(#blur)">hello world!</text>  </svg>

probably better use css or smil animation though (smil snippet provided @kaiido):

<svg width="250" height="100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">    <filter id="blur">      <fegaussianblur in="sourcegraphic" stddeviation="0">        <animate attributetype="xml" attributename="stddeviation" from="0" to="5" dur="1s" begin="0s; backward.end + 1s" id="forward" />        <animate attributetype="xml" attributename="stddeviation" from="5" to="0" dur="1s" begin="forward.end" id="backward" />      </fegaussianblur>    </filter>      <text x="15" y="50" font-size="35" filter="url(#blur)">hello world!</text>  </svg>


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -