Complimentary Color Palette

Complimentary Color Palette

Post by Patrick Carroll [Iocomp Software » Thu, 05 Dec 2002 06:35:21



Hello All,

Is there any way to convert a set of colors that look good on a random
background, and have them look "complimentary" and have good contrast with
the background? What I have is a chart with an arbitrary background color.
What I want to do is to automatically come up with a set of colors for
channels that will look good on that arbitarary background color.

Any ideas?

Cheers,
Patrick

 
 
 

Complimentary Color Palette

Post by Peter Haa » Thu, 05 Dec 2002 08:13:35


Hi Patrick,

Patrick Carroll [Iocomp Software] wrote in

Quote:> Is there any way to convert a set of colors that look good on a random
> background, and have them look "complimentary" and have good contrast with
> the background?

You should take a look in this thread:

Newsgroups: borland.public.delphi.graphics
Subject: Generating different colors
Date: Wed, 13 Nov 2002 13:44:27 +0100

Bye Peter.

 
 
 

Complimentary Color Palette

Post by Patrick Carroll [Iocomp Software » Fri, 06 Dec 2002 00:48:55


Hello Peter,

Thanks for the help.  But, I guess what i am looking for is a way to
automatically come up with a set of colors that will look good on an
arbitrary background.  I have found algorithms to create one good
contrasting color for a particular background, but I need to find many
colors that will look good on a background.

I already have a set of 30 colors that look good on Black.  I need to find a
way to somehow "massage" this list of colors to look good on any background.
Or find a way to come up with a small set of colors that have good contrast
with a given background.

Cheers,
Patrick Carroll


> Hi Patrick,

> Patrick Carroll [Iocomp Software] wrote in

> > Is there any way to convert a set of colors that look good on a random
> > background, and have them look "complimentary" and have good contrast
with
> > the background?

> You should take a look in this thread:

> Newsgroups: borland.public.delphi.graphics
> Subject: Generating different colors
> Date: Wed, 13 Nov 2002 13:44:27 +0100

> Bye Peter.

 
 
 

Complimentary Color Palette

Post by Ernest Fairchil » Fri, 06 Dec 2002 01:12:36




Quote:> Hello Peter,

> Thanks for the help.  But, I guess what i am looking for is a way to
> automatically come up with a set of colors that will look good on an
> arbitrary background.  I have found algorithms to create one good
> contrasting color for a particular background, but I need to find many
> colors that will look good on a background.

> I already have a set of 30 colors that look good on Black.  I need to
find a
> way to somehow "massage" this list of colors to look good on any
background.
> Or find a way to come up with a small set of colors that have good
contrast
> with a given background.

I was just messing around in CorelDraw to see *how* to accomplish this,
and in CorelDraw, I can easily accomplish it by using the HSB color space.
Basically, the HSB (Hue, Saturation, Brightness) color space uses the Hue
as if it were a wheel, marked in 360 degrees. If the hue of the background
color, for example, rotates +20 degrees, you rotate your other colors +20
degrees and you'd be fine.

That said, I've never heard of a converter for Delphi for RGB to HSB color
space and back. Perhaps someone else has one.

Have a great day!

Ernest
_____________________
"Funny, I don't remember being absent minded."

Visit my website at http://www.public.asu.edu/~ernestf

 
 
 

Complimentary Color Palette

Post by Peter Haa » Fri, 06 Dec 2002 02:36:45


Hi Ernest,


Quote:> That said, I've never heard of a converter for Delphi for RGB to HSB color
> space and back. Perhaps someone else has one.

Take a look to the mosted suggested homepage in this newsgroup :-)
e.g. http://homepages.borland.com/efg2lab/Graphics/Colors/HSV.htm

In the other thread, I have describe a possible problem with this
method.

Bye Peter.

 
 
 

Complimentary Color Palette

Post by Ernest Fairchil » Fri, 06 Dec 2002 03:46:00




<SNIP>

Quote:

> I then convert each color and the background to HSB, add the Hues of
both
> colors, and then convert the color back to RGB.  It works most of the
time,
> but generally the brightness of some of the colors are too bright when
the
> background is too bright, or too dark when the background is too dark.
Have
> any suggestions on coming up with the appropriate brightness settings?

You may want to try inverting the brightness value. For example, if the
brightness of the background is 30, make the brightness of the foreground
color 70, and vice versa. Mind you, I don't know if that would work, but
it might give you a starting point.

Have a great day!

Ernest
_____________________
"Funny, I don't remember being absent minded."

Visit my website at http://www.public.asu.edu/~ernestf

 
 
 

Complimentary Color Palette

Post by Patrick Carroll [Iocomp Software » Fri, 06 Dec 2002 03:31:35


Hello Ernest,

Thanks for the tip Ernest.  I found some C++ functions to convert between
RGB and HSB, and converted them to Pascal (hopefully correctly)...
//==========================================================================
====
procedure TForm1.RGBtoHSB(const r, g, b: Integer; var h, s, br : Double);
var
  largestColor : Integer; // holds the largest color (rgb) at the start
  lowestColor  : Integer; // opposite of above
  hue          : Double; // it puts the "h" in "hsb"
  saturation   : Double;// "s"
  brightness   : Double; // and the "b"
  redRatio     : Double;
  greenRatio   : Double;
  blueRatio    : Double;
begin
  // assign largestColor to the greater of the red or green
  if (r <= g) then
    largestColor := g
  else
    largestColor := r;

  // now see if blue is bigger
  if (b > largestColor) then
    largestColor := b;

  // set lowestColor = to the smallest value
  if (g < r) then
    lowestColor := g
  else
    lowestColor := r;

  if (b < lowestColor) then
    lowestColor := b;

  // brightness is calculated like so.
  brightness := largestColor / 255.0;

  // if the largestColor isn't zero (so we don't divide by zero) set the
variable
  // to the difference of the two as a percentage of the largest
  if (largestColor <> 0) then
    saturation := (largestColor - lowestColor) / largestColor
  else
    saturation := 0.0;

  if (saturation = 0.0) then
    hue := 0.0
  else
    begin
      //some temporary variables to figure out the hue
      redRatio   := (largestColor - r) / (largestColor - lowestColor);
      greenRatio := (largestColor - g) / (largestColor - lowestColor);
      blueRatio  := (largestColor - b) / (largestColor - lowestColor);

      // depending on which of the 3 was the highest, we calculate our hue.
      if (r = largestColor) then
        hue := blueRatio - greenRatio
      else if (g = largestColor) then
        hue := (2.0 + redRatio) - blueRatio
      else // blue is largest
        hue := (4.0 + greenRatio) - redRatio;

      // divide it by 6
      hue := hue /6.0;

      // I don't know if this prevents us from being negative (as in the
worst outcome from the above
      // operations is -1, or if this does something different).
      if (hue < 0.0) then
        hue := hue + 1;
   end;

  //Pass Back Values
  h := hue;
  s := saturation;
  br := brightness;
end;
//==========================================================================
====
procedure TForm1.HSBtoRGB(const hue, saturation, brightness: Double; var r,
g, b: Integer);
const
  max = 255;
var
  h : Double;
  f : Double;
  p : Double;
  q : Double;
  t : Double;
begin

  if(saturation = 0) then
    begin
      r := trunc(brightness * 255);
      g := trunc(brightness * 255);
      b := trunc(brightness * 255);
    end
  else
    begin
      h := (hue - floor(hue)) * 6.0;
      f := h - floor(h);
      p := brightness * (1.0 - saturation);
      q := brightness * (1.0 - saturation * f);
      t := brightness * (1.0 - (saturation * (1.0 - f)));

      case trunc(h) of
        0: begin
             r := trunc(brightness * 255);
             g := trunc(t * max);
             b := trunc(p * max);
           end;
        1: begin
             r := trunc(q * max);
             g := trunc(brightness * max);
             b := trunc(p * max);
           end;
        2: begin
             r := trunc(p * max);
             g := trunc(brightness * max);
             b := trunc(t * max);
           end;
        3: begin
             r := trunc(p * max);
             g := trunc(q * max);
             b := trunc(brightness * max);
           end;
        4: begin
             r := trunc(t * max);
             g := trunc(p * max);
             b := trunc(brightness * max);
           end;
        5: begin
             r := trunc(brightness * max);
             g := trunc(p * max);
             b := trunc(q * max);
           end;
      end;
   end;
end;
//==========================================================================
====

I then convert each color and the background to HSB, add the Hues of both
colors, and then convert the color back to RGB.  It works most of the time,
but generally the brightness of some of the colors are too bright when the
background is too bright, or too dark when the background is too dark.  Have
any suggestions on coming up with the appropriate brightness settings?

Cheers,
Patrick




<SNIP>
> That said, I've never heard of a converter for Delphi for RGB to HSB color
> space and back. Perhaps someone else has one.

> Have a great day!

> Ernest
> _____________________
> "Funny, I don't remember being absent minded."

> Visit my website at http://www.public.asu.edu/~ernestf

 
 
 

1. complimentary colors

Does anyone know where I can find a complimentary color chart on the web
or anyplace else? I have a redish color and I want to know some colors
that would work with it.

Thanks,
Bill

--
----------------------------------------------------------

|           http://soli.inav.net/~blynch/                |
----------------------------------------------------------

2. Combined filtering/resampling

3. Calculate Complimentary Color from RGB value

4. OpenGL v1.1 comments -- edge flagging

5. Generate a common 256 color palette - RĂ©aliser une palette commune de 256 couleurs

6. Plotting field lines in 3-D

7. Color questions: color systems, "black bodies", EGB palette

8. How's my cat?

9. Color palette for 256 color VGA rainbow

10. NEED INFO: NTSC/PAL Color Conversion (actually color palette conversion)

11. color palette not accessible in 256+ color settings

12. Getting the palette color of a system color

13. Bitmap Color Palette editing-VB4 16 bit 256 color