List Info

Thread: Stroke property for feFlood filter




Stroke property for feFlood filter
user name
2006-04-24 08:01:11
Hi Cameron,

> Sure, you can just use a 'rect' to draw the
background and then display
> the text atop.  If you need to make sure that the rect
covers exactly
> the area of the text, you can use some script:
> 
>   <svg xmlns="http://www.w3.org/2000/svg
"
>        version="1.1"
font-size="24" width="400"
height="400">
>     <rect id="theTextBackground"
fill="yellow" width="0"
height="0"/>
>     <text id="theText"
x="100" y="100">This is some
text.</text>
>     <script>
>       var r =
document.getElementById("theTextBackground");
>       var t =
document.getElementById("theText");
>       var bbox = t.getBBox();
>       r.setAttributeNS(null, "x", bbox.x);
>       r.setAttributeNS(null, "y", bbox.y);
>       r.setAttributeNS(null, "width",
bbox.width);
>       r.setAttributeNS(null, "height",
bbox.height);
>     </script>
>   </svg>


getBBox and getComputedTextLength is returning the required
values 
after 'Text' Element has added in RootElement. But is it
possible to create 
the rectangle while creating the 'Text' Element?

Element text = doc.createElementNS(svgNS,
"text");
Text value =
doc.createTextNode("100.100.10.10");
text.appendChild(value);
text.setAttributeNS(null, "text-decoration",
"none");
text.setAttributeNS(null, "x",
"150");
text.setAttributeNS(null, "y",
"150");
text.setAttributeNS(null, "font-family",
"Arial");
text.setAttributeNS(null, "font-size",
"12");
text.setAttributeNS(null, "width",
"???") //i need to set width here.

Thanks,
Selva




------------------------------------------------------------
---------
To unsubscribe, e-mail: batik-users-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org

Stroke property for feFlood filter
user name
2006-04-24 08:08:33
Selva:
> getBBox and getComputedTextLength is returning the
required values 
> after 'Text' Element has added in RootElement. But is
it possible to create 
> the rectangle while creating the 'Text' Element?

Yes.

  Element text = doc.createElementNS(svgNS,
"text");
  Text value =
doc.createTextNode("100.100.10.10");
  text.appendChild(value);
  text.setAttributeNS(null, "text-decoration",
"none");
  text.setAttributeNS(null, "x",
"150");
  text.setAttributeNS(null, "y",
"150");
  text.setAttributeNS(null, "font-family",
"Arial");
  text.setAttributeNS(null, "font-size",
"12");
  rootElement.appendChild(text);
  var bbox = text.getBBox();
  Element rect = doc.createElementNS(svgNS,
"rect");
  rect.setAttributeNS(null, "x", bbox.x);
  rect.setAttributeNS(null, "y", bbox.y);
  rect.setAttributeNS(null, "width",
bbox.width);
  rect.setAttributeNS(null, "height",
bbox.height);
  rect.setAttributeNS(null, "fill",
"yellow");
  rootElement.insertBefore(rect, text);

-- 
 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-unsubscribexmlgraphics.apache.org
For additional commands, e-mail: batik-users-helpxmlgraphics.apache.org

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )