André Wobst venit, vidit, dixit 15.10.2009 11:08: > Am 15.10.2009 um 10:36 schrieb Michael J Gruber: > >> Alan G Isaac venit, vidit, dixit 15.10.2009 02:26: >>> On 10/14/2009 6:22 AM, Michael J Gruber wrote: >>>> c = canvas.canvas([style.linewidth(1)]) >>> >>> So I had wondered about this and did >>> not understand the documentation. >>> >>> If one applies a line style to a canvas, I take >>> it that it becomes the default for all stroke operations >>> (by that canvas), including draw operations? >> >> It seems so ;) >> It's not documented (online draw style is), but it works that way. > > See canvas constructor at http://pyx.sourceforge.net/manual/node17.html
I know that one, but is style.linewidth() an instance of trafo.trafo, canvas.clip, style.strokestyle or style.fillstyle? I tried anyways, and it worked, of course, because of the way attrs are handed down. > c = canvas() > c2 = canvas() > c.insert(c2, [style.linewidth(1)]) > > Maybe this is too much in terms of user friendliness, but I clearly > like this solution most. >From the user's perspective, this is completely unintuitive, because of the way that inserting a canvas on which you've stroked changes those lines after the fact, unless they've set their width explicitly, and because inserting a canvas inserts a reference or copy, not a deep (!) copy. Try and guess how many lines the following produces, and what width they will have. I know Andre will get it right ;) from pyx import * c = canvas.canvas() c2 = canvas.canvas() c.stroke(path.line(0,0,0,1)) c2.stroke(path.line(1,0,1,1)) c2.stroke(path.line(2,0,2,1), [style.linewidth(0.2)]) c.insert(c2, [style.linewidth(0.4)]) c.stroke(path.line(3,0,3,1)) c2.stroke(path.line(4,0,4,1)) c.writePDFfile(__file__[:-3]) How many (even long time) users will get it right? I don't propose changing the inherent pyx structure which leads to this. But I would really recommend against relying on it for something as simple as setting a default line style. Cheers, Michael SPOILER SPOILER SPOILER SPOILER SPOILER SPOILER SPOILER SPOILER SPOILER Full disclosure: I thought the line at 2 has width 0.4 (because of the order of "assignments" of linewidths) and wasn't sure whether the one at 4 would appear. But I remembered experimenting once with the difference between inserting a canvas, a copy of a canvas and a *deep* copy of a canvas, which explains this. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ PyX-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyx-user
