André Bouchet wrote:
> When filling a closed path in a PyX script, for example with the color
> green, every point inside the closed path is colored green. This
> corresponds to the postscript operator 'fill'. There is another
> postscript operator 'eofill' (exclusive or fill), which fills the
> interior of the closed path like a checkerboard. That way to fill a path
> is common to many drawing softwares, like inkscape for example. Is it
> possible to do the same thing with PyX ?
>
> Thank you for your answer,
>
> André
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> PyX-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyx-user
>
>
>
This is usually called the 'winding rule'. In PDF the Path-painting
operator f is the one normally used in PyX, and
uses the 'non-zero winding number' rule.
The alternative operator, f* uses the 'Even-Odd' rule, and as far as I
can see is not implemeted in PyX.
Fot a quick hack to show the possibility, go to the file deco.py, line
277, and (temporarily) change the f to f*:
# *****************************************************
else:
# only fill fillpath - for the moment
if self.fillstyles:
file.write("q\n") # gsave
_writefillstyles(self.fillstyles, context(),
registry, bbox)
file.write("f*\n") # fill (changed here from f to f* for
the EVEN ODD rule )
bbox += fillpath.bbox()
# ********************************************************
A suitable test file to show the difference is:
from pyx import *
c = canvas.canvas()
W=2
numofstripes=3
A=(numofstripes+1.5)*W
w = W / 2.0
Left=w
Right=A-w
Bottom=w
Top=A-w
mypath1 = path.path(path.moveto(0,0),path.lineto(0,A),
path.lineto(A,A),path.lineto(A,0),
path.closepath())
mypath2=path.path()
for n in range(1,numofstripes+1):
a,b=n*W,n*W+w
mypath2.append(path.moveto(a,Bottom))
mypath2.append(path.lineto(a,Top))
mypath2.append(path.lineto(b,Top))
mypath2.append(path.lineto(b,Bottom))
mypath2.append(path.closepath())
mypath2.append(path.moveto(Left,a))
mypath2.append(path.lineto(Right,a))
mypath2.append(path.lineto(Right,b))
mypath2.append(path.lineto(Left,b))
mypath2.append(path.closepath())
mypath2.append(path.moveto(Left,(Top+Bottom)/2.0))
mypath2.append(path.lineto((Left+Right)/2.0,Bottom))
mypath2.append(path.lineto(Right,(Top+Bottom)/2.0))
mypath2.append(path.lineto((Left+Right)/2.0,Top))
mypath2.append(path.closepath())
c.stroke(mypath1, [style.linewidth.thin])
c.fill(mypath2, [style.linewidth.thin])
c.writePDFfile("checkerboard")
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user