Hi,

I experienced a problem with the "rgb()" function.
These two calls should (and do) return identical results:

  rgb(255, 128, 128, maxColorValue=255)
  rgb(1.0, 0.5, 0.5, maxColorValue=1)

However, when I specify a non-default "alpha" channel (a "transparent"
colour), I get differing results:

  rgb(255, 128, 128, alpha=0.5, maxColorValue=255)
  rgb(1.0, 0.5, 0.5, alpha=0.5, maxColorValue=1)

where only the latter version seems to yield the actually intended
result.

Is this a bug?


You can check the actual colours' appearance this way:

  barplot(3:5, col=rgb(255, 128, 128, maxColorValue=255))
  barplot(3:5, col=rgb(1.0, 0.5, 0.5, maxColorValue=1))

  barplot(3:5, col=rgb(255, 128, 128, alpha=0.5, maxColorValue=255))
  barplot(3:5, col=rgb(1.0, 0.5, 0.5, alpha=0.5, maxColorValue=1))

The apparently buggy version in this case seems to return white instead
of red.


Thanks,

Christian
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to