From: Andre W. <wo...@us...> - 2005-09-14 11:16:23
|
Hi, On 13.09.05, Rich Drewes wrote: > The "angle" argument doesn't seem to result in rotations of the placed > text. Is it supposed to? No, it's the direction used for alignment. We could (and even should at least have an option to) do this perpendicular to the path. To come back to your original question, you should add a rotation to the textattrs. Unfortunately you'll overwrite the text.halign.center and text.vshift.mathaxis by that. The PyX-way would be to merge those attributes the the additional attributes. So the code would look like: class textdeco(deco.deco, attr.attr): def __init__(self, text, textattrs=[], angle=0, textdist=0.2, relarcpos=0.5, texrunner=text.defaulttexrunner): self.text = text self.textattrs = textattrs self.angle = angle self.textdist = textdist self.relarcpos = relarcpos self.texrunner = texrunner def decorate(self, dp): x, y = dp.path.at(self.relarcpos * dp.path.arclen()) textattrs = attr.mergeattrs([text.halign.center, text.vshift.mathaxis] + self.textattrs) t = self.texrunner.text(x, y, self.text, textattrs) t.linealign(self.textdist, math.cos(self.angle*math.pi/180), math.sin(self.angle*math.pi/180)) dp.ornaments.insert(t) return dp c = canvas.canvas() c.stroke(path.curve(0, 0, 3, 0, 2, 5, 5, 5), [textdeco("Hello, world!", textattrs=[trafo.rotate(45)])]) c.writeEPSfile("textdeco") André -- by _ _ _ Dr. André Wobst / \ \ / ) wo...@us..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ |