xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cameron McCormack <cam-batik-us...@aka.mcc.id.au>
Subject Re: Replace color in entire document
Date Wed, 01 Feb 2006 22:03:27 GMT
Hi Andre.

Andr vila:
> I want to change specific colors in a document (say, replace all green
> for red in the entire SVG). What would be the best way of doing it?

I think it would be better to do it in a non-Batik-specific way.  In SVG
1.1 there is no 'solidColor' paint server as there is in 1.2, but you
can achieve the same thing with a 'linearGradient' with a single stop.
This shouldn't be any worse wrt performance than using a plain solid
colour as your fill.

  <svg xmlns="http://www.w3.org/2000/svg"
       version="1.1" width="400" height="400">
    <linearGradient id="c">
      <stop id="s" offset="0" stop-color="orange"/>
    </linearGradient>
  
    <rect width="100" height="100" fill="url(#c)"
          onclick="document.getElementById('s')
                           .setAttributeNS(null, 'stop-color', 'pink');
                   evt.target.setAttributeNS(null, 'fill', 'url(#c) ');"/>
  </svg>

Unfortunately there is a bug with Batik where updates to a referenced
paint server do not cause an object to be repainted, which is why I have
the

  evt.target.setAttributeNS(null, 'fill', 'url(#c) ');

line in there to force the rect to be repainted.

Cameron

-- 
 Cameron McCormack			ICQ: 26955922
 cam (at) mcc.id.au			MSN: cam (at) mcc.id.au
 http://mcc.id.au/			JBR: heycam (at) jabber.org

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


Mime
View raw message