Hi,
On 26.12.06, William Henney wrote:
> > 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")
>
> ----------------------------------------------------------------
Well, usually you should use a combined stroke and fill operation. See
http://pyx.sourceforge.net/examples/drawing/strokefill.html for some
explanation.
However, for transparency this does not work. It's due to the fact,
that transparency needs to be set by an extended graphics state
modification and this is done for stroke and fill operations at the
same time (neglecting some strokeonly and fillonly settings in PyX's
internal graphics stack). Clearly a bug. I'll fix it but I can't
easily do that at the moment, since I have unreleased code in color.py
and other area's and need to get into a clear state with my code base
before addressing this issue.
Anyway, thanks for reporting this bug ...
André
--
by _ _ _ Dr. André Wobst
/ \ \ / ) [EMAIL PROTECTED], http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
-------------------------------------------------------------------------
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