Open GoogleCodeExporter opened 9 years ago
Hi,
This is the correct behavior for Text--- usually people will want to set a
label that
follows data through a coordinate transformation, but not distort with it.
This is
where SVGFig differs from SVG: in SVG, a transformation completely distorts
whatever
it's applied to, including line widths and the radii of data points, which is
not
what people want when they make mathematical figures.
I can't remember the interface, but there's some option for Text (or a
relative) that
calculates a linear approximation to the coordinate transformation at the point
where
it is to be drawn and asks SVG to linear-transform the resulting SVG("text").
But that's just a linear transformation which will only look right if the text
string
is short and the coordinate transformation is not too non-linear at that point.
What
you'd like to do, transform a Line and then put the text along it, is definitely
possible, though it is an SVG feature, rather than SVGFig. You can transform a
Line
and get SVGFig to output the resulting SVG("path", d="..."). Then give that
path an
"id" attribute and create an SVG("textPath", ...) element. See
http://www.w3.org/TR/SVG11/text.html#TextOnAPath for how to get SVG to do this
for
you. The SVGFig part is just generating the curvy path and linking things up
into an
SVG document more conveniently.
There's a third option (if you're still looking for more), and that is to
follow the
example of the SVGFig logo. I created the text in Inkscape, then used an
Inkscape
feature which converted the text into a path. In SVGFig, I did a pathToPath
conversion (not necessary in 2.0) and applied a generic non-linear
transformation.
That messed things up a bit, because Inkscape used the minimum number of control
points, and the coordinate transformation only moved the control points. So I
went
back to Inkscape and additionally used the "add more points" feature to make
the text
full of nearby control points, so that the coordinate transformation distorted
it
more naturally.
Good luck!
Original comment by jpivar...@gmail.com
on 12 Jun 2008 at 3:20
Ok, thanks for your recommendations.
If I got it right, I should create the textPath with the SVG command, and not
using
svfig's "Text" command. I'll look into that. I'm a bit confused by the "get
SVGFig to
output the resulting SVG("path"... and give it an id" is that doable from
svgfig or
do I need manual intervention?
Never mind, after some fiddling around I got it to work. See the following small
sample :-) Thanks!!
from svgfig import *
from math import *
import random
caja = Rect(0,1, 2,2, fill="blue", stroke="red")
path1 = Line (0.2, 1.2, 1.8, 1.2, id="path1")
text1 = SVG("text", SVG("textPath", "svgfig", xlink__href="#path1"),
font_size=5,
stroke="none", fill="white", text_anchor="start")
Fig(Fig(caja, path1, text1, trans="-y*cos(x+0.6),
y*sin(x+0.6)")).SVG(window(-6, 6,
-6, 6)).save()
Original comment by agus...@gmail.com
on 13 Jun 2008 at 10:49
Original issue reported on code.google.com by
agus...@gmail.com
on 12 Jun 2008 at 1:40