Hans,

Hmmm. Yes, this is a bug. You're really doing quite a hard test on our 
internals ... :-)

What happens here, is that the curvedtext decorator actually does not apply the 
mirror trafo at all. The curved text decorator works by reading all text items 
(each character is typeset for itself due to an internal "singlecharmode") and 
applies a trafo to each character depending on its position on the path. By 
that, all global transformations become ignored (!!!), as they have been 
applied to the text items globally and are not taken into account while reading 
the characters one by one. If I'm right, we just need to apply the trafos to 
each character, and this can be done by the following patch:

    andre@mbp:~/python/pyx$ svn diff pyx/deco.py
    Index: pyx/deco.py
    ===================================================================
    --- pyx/deco.py     (revision 3340)
    +++ pyx/deco.py     (working copy)
    @@ -610,13 +610,15 @@
             t = texrunner.text(0, 0, self.text, textattrs, singlecharmode=1)
             t.ensuredvicanvas()
     
    +        texttrafos = attr.getattrs(textattrs, [trafo.trafo_pt])
    +
             c = canvas.canvas()
             for item in t.dvicanvas.items:
                 bbox = item.bbox()
                 if bbox:
                     x = item.bbox().center()[0]
                     atrafo = dp.path.trafo(textpos+x)
    -                c.insert(item, [trafo.translate(-x, 0), atrafo])
    +                c.insert(item, [trafo.translate(-x, 0)] + texttrafos + 
[atrafo])
                     if self.exclude is not None:
                         dp.excluderange(textpos+bbox.left()-self.exclude, 
textpos+bbox.right()+self.exclude)
                 else:

I just submitted this fix in changeset 3348.

I wonder if you find other issues with this y-axis inversion. We'll see, good 
luck!

Best,


André


Am 11.05.2013 um 23:26 schrieb Hans L:

> Ok,your example works.  It appears that my issue is specifically with curved 
> text.  Transformations do not seem to apply at all.
> 
> Here is a modified example from 
> http://pyx.sourceforge.net/examples/text/textalongpath.html
> 
>     from pyx import *
> 
>     c = canvas.canvas(attrs=[trafo.mirror()])
> 
>     p = path.path(path.moveto(-2, 0), path.curveto(-1, 0, -1, 1, 0, 1), 
> path.curveto(1, 1, 1, 0, 2, 0))
> 
>     c.stroke(p, [deco.curvedtext("\PyX{} is fun!", 
> textattrs=[trafo.mirror()]),
>                  deco.curvedtext("left", textattrs=[text.halign.left, 
> text.vshift.mathaxis, trafo.mirror()], arclenfrombegin=0.5, exclude=0.1),
>                  deco.curvedtext("right", textattrs=[text.halign.right, 
> text.vshift.mathaxis, trafo.mirror()], arclenfromend=0.5, exclude=0.1)])
> 
>     c.writePDFfile("textalongpath")
> 
> 
> Is this a bug?
> 
> 
> 
> On Sat, May 11, 2013 at 4:00 PM, André Wobst <[email protected]> 
> wrote:
> Hans,
> 
> Sorry, I should have read your question more carefully.
> 
> Well, there's probably no other options than applying transformations. A 
> simple example works rather well:
> 
>     from pyx import *
>     c = canvas.canvas([trafo.mirror()])
>     c.stroke(path.line(0, 0, 2, 2))
>     c.text(1, 1, "Hello, world!", [trafo.mirror()])
>     c.writePDFfile()
> 
> Unfortunately, we don't have a hook to apply the mirror trafo to all text 
> boxes. You may define you some convenience method or alter the texrunner 
> instance ... it probably depends on the use-case what is best.
> 
> 
> André
> 
> 
> Am 11.05.2013 um 22:42 schrieb Hans L:
> 
> > I'm not using graphs specifically, I just mean to flip the y orientation of 
> > general rendering to a canvas.
> >
> > Hans
> >
> >
> > On Sat, May 11, 2013 at 3:34 PM, André Wobst <[email protected]> 
> > wrote:
> > Hi Hans,
> >
> > You can use the reverse flag of the axis, see 
> > http://pyx.sourceforge.net/manual/axis.html#graph.axis.axis.linear, or fix 
> > the axis range manually and set max to be smaller than min (which sounds a 
> > little crazy, but it perfectly does the trick as well).
> >
> > HTH, André
> >
> > Am 11.05.2013 um 21:55 schrieb Hans L:
> >
> > > Hello, I am new to using PyX and was wondering if it is possible to 
> > > invert the Y axis so the top left of page is 0,0 and the y value 
> > > increases as you go towards the bottom of the page?
> > >
> > > I experimented with passing a trafo to the canvas constructor:
> > > trafo.trafo(matrix=((1, 0), (0, -1)), vector=(0, canvasheight))
> > >
> > > This seems to work ok for graphics, but then of course all text is upside 
> > > down.
> > > I tried applying a similar y flipping transformation to the textattrs to 
> > > upright it again, but it did not seem to do anything.
> > >
> > > Is there any simple solution to this?
> > >
> > > Thanks,
> > > Hans
> > >
> > > ------------------------------------------------------------------------------
> > > Learn Graph Databases - Download FREE O'Reilly Book
> > > "Graph Databases" is the definitive new guide to graph databases and
> > > their applications. This 200-page book is written by three acclaimed
> > > leaders in the field. The early access version is available now.
> > > Download your free book today! 
> > > http://p.sf.net/sfu/neotech_d2d_may_______________________________________________
> > > PyX-user mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/pyx-user
> >
> > --
> > by  _ _      _    Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim
> >    / \ \    / )   [email protected], http://www.wobsta.de/
> >   / _ \ \/\/ /    PyX - High quality PostScript and PDF figures
> >  (_/ \_)_/\_/     with Python & TeX: visit http://pyx.sourceforge.net/
> >
> >
> 
> --
> by  _ _      _    Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim
>    / \ \    / )   [email protected], http://www.wobsta.de/
>   / _ \ \/\/ /    PyX - High quality PostScript and PDF figures
>  (_/ \_)_/\_/     with Python & TeX: visit http://pyx.sourceforge.net/
> 
> 

-- 
by  _ _      _    Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim
   / \ \    / )   [email protected], http://www.wobsta.de/
  / _ \ \/\/ /    PyX - High quality PostScript and PDF figures
 (_/ \_)_/\_/     with Python & TeX: visit http://pyx.sourceforge.net/

Attachment: smime.p7s
Description: S/MIME cryptographic signature

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to