xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Schepers" <d...@schepers.cc>
Subject RE: defining a filter
Date Fri, 21 Jun 2002 19:38:40 GMT
Hi, Mark-

I don't use Batik very often, so forgive me if I go astray. However, I
believe that Batik want you to use "setAttributeNS" rather than
"setAttribute." I think that

el.setAttributeNS(null, "filter", "url(#myfilter)")

would work... or perhaps

el.style.setProperty("filter", "url(#myfilter)")

is better.

In any case, I have a simple drawing program that allows the user to create
and apply filters, so dynamic use of filters is definitely possible.

BTW, since a filter is not rendered on its own, you don't necessarily have
to put it into <defs>, though I always do. However, make sure you are
inserting it into the SVG, and not just the document. Something like:

<defs id='filterdefs'></defs>
[...]
var MyFilter = document.createElement('filter');
...
document.getElementById('filterdefs').appendChild(MyFilter);

should do the trick.

HTH-
-Doug

> -----Original Message-----
> From: Mark Vidov [mailto:mvidov@hotmail.com]
> Sent: Friday, June 21, 2002 2:17 PM
> To: batik-users@xml.apache.org
> Subject: defining a filter
>
>
> I'm probably missing an easy way to do this but I would like to add a new
> filter to an existing svg document so it can be used to
> dynamically change
> elements.
>
> I attempted to add the filter to the <defs> but doing so in response to
> documentLoadingComplete seems to be too late. Is there another way to do
> this? Should I be hooking into the building of the DOM tree at
> some point?
> Or is there a programmatic way to modify the defs or define the filter?
> Thanks for any advice.
>
>
> eg
> insert this into <defs>:
>   <filter id="myfilter" .../>
> modify an element in code:
>   el.setAttribute("filter", "url(#myfilter)")

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.371 / Virus Database: 206 - Release Date: 6/13/2002


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message