[Rd] polypath winding rule with transparency

Michael Sumner mdsumner at gmail.com
Wed Aug 3 08:47:16 CEST 2016


Hello,

it's probably worth adding that this is not a problem with pathGrob, only
polypath.

This code is sufficient to demonstrate the problem in Windows.

## overlapping, both clock-wise
x <- cbind(c(.1, .1, .6, .6, NA, .4, .4, .9, .9),
          c(.1, .6, .6, .1, NA, .4, .9, .9, .4))
## only a problem on Windows windows() and png()
plot(x);polypath(x, rule = "winding", col = "#BEBEBE80")

This code shows the same behaviour on different systems/devices.

## no problem on Windows/Linux/PNG/PDF ...
library(grid)
grid.newpage()
pushViewport(viewport(0.5, 0.5, width = 1, height = 1))
grid.draw(pathGrob(x[,1], x[,2], rule = "winding", gp = gpar(fill =
"#BEBEBE80")))

Cheers, Mike.

On Wed, 3 Aug 2016 at 16:24 Michael Sumner <mdsumner at gmail.com> wrote:

> Hi, I see different results in png() and pdf() for polypath() on Windows
> when using the "winding" rule
>
> ## overlapping, both clock-wise
> x <- cbind(c(.1, .1, .6, .6, NA, .4, .4, .9, .9),
>           c(.1, .6, .6, .1, NA, .4, .9, .9, .4))
>
> pfun <- function() {
>   plot(x)
>   polypath(x * 0.8 + 0.2,  rule = "winding", col = "#BEBEBE80")
>   polypath(x,  rule = "winding", col = "#BEBEBE80")
> }
>
> ## output  "windows.png/pdf" or "unix.png/pdf"
> label <- .Platform$OS.type
> png(sprintf("%s.png", label))
> pfun()
> dev.off()
> pdf(sprintf("%s.pdf", label))
> pfun()
> dev.off()
>
>
> Visually, the result in the "windows.png" file is as if the "evenodd" rule
> was specified. All other examples unix.pdf, unix.png, windows.pdf give me
> the expected result - which is "all bounded regions shaded grey, with two
> tones for the different regions of overlap". The unexpected result is the
> completely transparent region.
>
> Is this a known/expected difference on Windows?  I see the unexpected
> result in 3.3.1 and in R version 3.3.1 Patched (2016-07-27 r70991) on
> Windows.
>
> Cheers, Mike.
> --
> Dr. Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> 203 Channel Highway
> Kingston Tasmania 7050 Australia
>
> --
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-devel mailing list