Hi
On 12/26/06, kib2 <[EMAIL PROTECTED]> wrote:
> In pyx.trafo.trafo, I don't understand how the mirror is implemented.
>
> As far as I know, to obtain a mirror at line passing through (0,0) with
> the given angle "angle", the matrix should be like this:
> ((math.cos(2*angle),math.sin(2*angle)),(math.sin(2*angle),-math.cos(2*angle))).
>
>
> But it is given like this:
> ( (math.cos(phi)*math.cos(phi)-math.sin(phi)*math.sin(phi),
> -2*math.sin(phi)*math.cos(phi) ),
> (-2*math.sin(phi)*math.cos(phi),
> math.sin(phi)*math.sin(phi)-math.cos(phi)*math.cos(phi) ) )
>
> There are problems with i.e a 135 degrees given angle.
>
But these are exactly the same, except for the sign of the angle
(recall your high school trig identities!). Your matrix is correct
for angles measured clockwise from the x-axis, but PyX is assuming
that the angle is measured *anti*clockwise from the x-axis (which is
the more common convention I think). On the other hand, I don't see
why PyX has expanded out the double angle formulae - your version
seems to have a lower operation count.
> My other question is relative to the transparency in pdf output. The
> documentation is rather limited on this, and I found no sample.
> How can I fill a given path with transparency and stroke it (without
> transparency) at the same time ?
I don't think that you can do this with the built-in methods, but
there is no reason why you can't roll your own. Something like this:
----------------------------------------------------------------
import pyx
class mycanvas(pyx.canvas.canvas):
"Just like pyx.canvas.canvas, but adds a strokefill method."
def strokefill(self, path, strokeattrs=[], fillattrs=[], commonattrs=[]):
self.stroke(path, strokeattrs+commonattrs)
self.fill(path, fillattrs+commonattrs)
c = mycanvas()
p = pyx.path.circle(0, 0, 1)
translucent = pyx.color.transparency(0.7)
blue = pyx.color.rgb(0.1, 0.2, 0.5)
red = pyx.color.rgb(0.9, 0.4, 0.3)
# blue solid stroke, red translucent fill
c.strokefill(p, [blue], [red, translucent])
# red solid stroke, blue translucent fill, shifted
c.strokefill(p, [red], [blue, translucent], [pyx.trafo.translate(0.5, 0.5)])
c.writePDFfile("strokefilltest")
----------------------------------------------------------------
Cheers
Will
--
Dr William Henney, Centro de Radioastronomía y Astrofísica,
Universidad Nacional Autónoma de México, Campus Morelia
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user