On Tue, 9 Mar 2004 jasonmod@...262... wrote:
The way that the SVG spec wants us to do it is using the 'marker' approach. I've found it's kind of a pain to implement but in theory if we do it right, the files will work in any compliant SVG editor or viewer. Would you be interested in helping me finish implementing it? I can give you the run-down on what's left to do to get it working, as best as I know, if you'd like?
Sure.
Okay, cool. The way that SVG does markers is via the 'marker-start', 'marker-end', etc. style tags. Unlike most other style tags, like line caps, the markers use uri's that point elsewhere in the document for the definition of what to be drawn. I.e.: "marker-start:url(#mArrow);"
The place that the mArrow item is defined is in the <defs></defs> section of the SVG document. If you look on the screenshots page down at the bottom, there's an example I made of some markers, and you can download the svg document by clicking on the screenshot to see how the SVG is laid out.
The code in the codebase currently has some buttons that will put the marker-start style tag on the lines, which is fine if mArrow is already present in the <defs> section (i.e., if you manually write it into the doc). So the next step is to figure out how to make it automatically insert it when the user clicks that button and adds an arrowhead to a line in the drawing. Ideally, we should also remove the def when there are no longer any lines using it.
The gradients work in a very analogous way, so it's possible that code can be stolen from there. I haven't looked at the gradient code at all so am not sure what's there. Would you like to take a look at it and see if you can understand how it handles adding/removing its defs items, and if the code could be reused in some fashion?
If we can get this defs insert capability done, I *think* that'll be enough to get the feature officially included.
Beyond that, then things get fun. ;-) Ultimately I think we want some way to let users define their own markers.
Bryce