On Mon, 21 May 2007, John Fox wrote: > Dear r-helpers, > > I wonder whether, given the "#rrggbb" representation of a colour, there is a > simple way to select the complementary colour, also expressed as a "#rrggbb" > string.
Is the complementary color uniquely defined? My understanding is that you can take opposite colors on a color wheel, but there are of course various color wheels available. With "colorspace" you can experiment with this, e.g.: x <- "#81A9D0" y_hcl <- as(hex2RGB(x), "polarLUV") [EMAIL PROTECTED], "H"] <- [EMAIL PROTECTED], "H"] + 180 y_hcl <- hex(y_hcl) which is a bit more balanced than y_hsv <- as(hex2RGB(x), "HSV") [EMAIL PROTECTED], "H"] <- [EMAIL PROTECTED], "H"] + 180 y_hsv <- hex(y_hsv) hth, Z ______________________________________________ [email protected] mailing list 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.
