A
Aidan Gauland
I'm playing around with scripting SVG with ECMAScript, and I have
reached the point where my document is full of hard-coded (attribute)
values. There are three values to which most other values are relative.
(In this case, there are a bunch of shapes positioned with respect to a
specific circle.) Even after wading through the SVG specification
<http://www.w3.org/TR/SVG/>, I am at a loss as to how to refactor my XML
code. I basically want to say, "you, rectangle, your origin is the
top-left corner of this circle's bounding-box." But I also have a
circle in a <clipPath> who's cx and cy values are those of another
circle *plus* that other circle's stroke width. And to make it even
trickier, the target circle is within a symbol within the document's
<defs> element. It's all just a bit crazy.
It seems that being able to, within an attribute's value,
refer to the value of another entity's attribute would be the cleanest
way to tidy up my document. But XML does not allow for this, does it?
Can anyone offer any advice on how to keep XML (SVG in particular) tidy
in this manner, and avoid hard-coding values?
Regards,
Aidan Gauland
reached the point where my document is full of hard-coded (attribute)
values. There are three values to which most other values are relative.
(In this case, there are a bunch of shapes positioned with respect to a
specific circle.) Even after wading through the SVG specification
<http://www.w3.org/TR/SVG/>, I am at a loss as to how to refactor my XML
code. I basically want to say, "you, rectangle, your origin is the
top-left corner of this circle's bounding-box." But I also have a
circle in a <clipPath> who's cx and cy values are those of another
circle *plus* that other circle's stroke width. And to make it even
trickier, the target circle is within a symbol within the document's
<defs> element. It's all just a bit crazy.
It seems that being able to, within an attribute's value,
refer to the value of another entity's attribute would be the cleanest
way to tidy up my document. But XML does not allow for this, does it?
Can anyone offer any advice on how to keep XML (SVG in particular) tidy
in this manner, and avoid hard-coding values?
Regards,
Aidan Gauland