views:

55

answers:

0

(This question might be too difficult, and maybe not worth the hassle to solve - however, if there is an easy solution - I would be curious to know)

Let's say I create an image (using the grid package) which looks like this:

require(grid)
grid.newpage()
grid.polygon(x=c((0:4)/10, rep(.5, 5), (10:6)/10, rep(.5, 5)),
             y=c(rep(.5, 5), (10:6/10), rep(.5, 5), (0:4)/10),
             id=rep(1:5, 4),
             gp=gpar(fill=1:5))

But now, what if I wish to have some of the polygons only partially filled (let's say one will be 1/3 filled and another 1/2 filled and the other fully filled with color) So it would look like partially filled glass of water.

I imagine it can be done when constructing the polygons, the question is, assuming I want something to calculate the new polygons only based on the proportions I give it - how can that be done.

The motivation for my question comes from wanting to present another layer of information on logo plots (see the function seqLogo in the package seqLogo)

Thanks.