ipe-tools icon indicating copy to clipboard operation
ipe-tools copied to clipboard

svgtoipe: Support for Arrowtips

Open derlunz opened this issue 9 years ago • 4 comments

I've hacked together code for parsing and writing arrows in svg files. See this commit in my svg-markers branch.

Collecting and writing marker/arrow definitions seems to work. Still I am doing something wrong, as the arrows won't show when loaded with ipe release 7.2.6.

svgtoipe doesn't use the new stylesheet format. But as I understand it, the following fragments should suffice to produce arrowed paths

Within styesheets define the symbol: <ipestyle> <symbol name="Arrow1Lend" xform="yes"> <path matrix="-0.8 0 0 -0.8 -10 0" stroke="0 0 0" filltest-markers="0 0 0" pen="1"> 0 0 m 5 -5 l -12.5 0 l 5 5 l h </path> </symbol> <ipestyle>

And later in the document use those symbol: <path stroke="black" arror="Arrow1Lend" rarror="Arrow1Lend"> 81 130 m 120 130 l </path>

Could you help me to clarify that issue?

derlunz avatar Dec 11 '16 11:12 derlunz

Have a look at this thread: http://lists.science.uu.nl/pipermail/ipe-discuss/2016-June/001807.html

  1. The symbol must have a name of the form "arrow/xyz(spx)". xyz will then be the name to use in the path object to use this arrow.

  2. Do not use xform="yes".

  3. You probably want to use sym-stroke and sym-pen in the arrow definition to make the arrow color and line width depend on the path settings.

Here is a modified definition:

<symbol name="arrow/Arrow1Lend(spx)">
<path matrix="-0.08 0 0 -0.08 0 0" stroke="sym-stroke" fill="sym-stroke" pen="1">
0 0 m
5 -5 l
-12.5 0 l
5 5 l
h
</path>
</symbol>

You can then use this from a path like this:

<path stroke="black" arrow="Arrow1Lend/normal" rarrow="Arrow1Lend/normal">
81 130 m
120 130 l
</path>

otfried avatar Dec 11 '16 13:12 otfried

For your marker, the name of the symbol must be of the form "mark/xyz(sx)" where xyz will be the name of the marker. Do not use xform="yes". Have a look at the definitions in basic.isy for some examples.

otfried avatar Dec 11 '16 13:12 otfried

Thanks for the help. My plan to add the following stylesheets in the converted ipe file:

  • one <ipestyle/> for a copy of basic.isy
  • one for the page dimensions
  • one for other svg defined stuff

Would you'd rather have a straight string copy, or a semi-copy with values, for ocupacity, and colors generated by the svgtoipe? Another option would be to lookup and read basic.isy from the system path. Do you think it is worth the trouble?

derlunz avatar Dec 11 '16 16:12 derlunz

Svgtoipe currently does not include basic.isy at all, since all attributes are either absolute or taken from the SVG. Why exactly to you want to change this?

Separating page dimensions from other SVG definitions sounds like a good idea to me.

If you want to include the standard basic.isy, you should not modify it---it will be overwritten if the user ever executes Update stylesheets. You should put basic.isy at the bottom of the stylesheet cascade, and let another sheet with the SVG definitions override it.

You should certainly not add a copy of basic.isy to svgtoipe.py - that's inelegant, and it's quite likely to change in the future. Either you need to read it from the system, or include a dummy version like this:

<ipestyle name="basic">
</ipestyle>

Then the user can press Shift+Ctrl+U in Ipe after opening the file to replace this by the real basic.isy. (annotate.py uses this trick, but then runs ipescript update-style.)

otfried avatar Dec 11 '16 16:12 otfried