Next: , Previous: draw, Up: Drawing commands


5.2 fill

void fill(picture pic=currentpicture, path g, pen p=currentpen);

Fill the interior region bounded by the cyclic path g on the picture pic, using the pen p.

There is also a convenient filldraw command, which fills the path and then draws in the boundary. One can specify separate pens for each operation:

void filldraw(picture pic=currentpicture, path g, pen fillpen=currentpen,
              pen drawpen=currentpen);

This fixed-size version of fill allows one to fill an object described in PostScript coordinates about the user coordinate origin:

void fill(pair origin, picture pic=currentpicture, path g, pen p=currentpen);

This is just a convenient abbreviation for the commands:

picture opic;
fill(opic,g,p);
add(origin,pic,opic);

Lattice gradient shading varying smoothly over a two-dimensional array of pens p, using fillrule fillrule, can be produced with

void latticeshade(picture pic=currentpicture, path g,
                  pen fillrule=currentpen, pen[][] p)
The pens in p must belong to the same color space. One can use the functions rgb(pen) or cmyk(pen) to promote pens to a higher color space, as illustrated in the example file latticeshading.asy.

Axial gradient shading varying smoothly from pena to penb in the direction of the line segment a--b can be achieved with

void axialshade(picture pic=currentpicture, path g,
                pen pena, pair a,
                pen penb, pair b);

Radial gradient shading varying smoothly from pena on the circle with center a and radius ra to penb on the circle with center b and radius rb is similar:

void radialshade(picture pic=currentpicture, path g,
                 pen pena, pair a, real ra,
                 pen penb, pair b, real rb);
Illustrations of radial shading are provided in the example files shade.asy and ring.asy.

Gouraud shading using fillrule fillrule and the vertex colors in the pen array p on a triangular lattice defined by the vertices z and edge flags edges is implemented with

void gouraudshade(picture pic=currentpicture, path g,
                  pen fillrule=currentpen, pen[] p, pair[] z,
                  int[] edges);
The pens in p must belong to the same color space. Illustrations of Gouraud shading are provided in the example files Gouraud.asy and sphere.asy.

The following routine uses evenodd clipping together with the ^^ operator to unfill a region:

void unfill(picture pic=currentpicture, path g);