Author Topic: Color invert problem  (Read 15632 times)

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Color invert problem
« on: January 31, 2010, 09:03:17 PM »
I'm inverting colors with:

v=255-v; where v is r, g, b component. The problem is that I want to have invert colors, but darker and related to the lightness of the source color. In other words dark complementary color shadows. Any simple way to do that?

corremn

  • Rogueliker
  • ***
  • Posts: 700
  • Karma: +0/-0
  • SewerJack Extraordinaire
    • View Profile
    • Demise RogueLike Games
Re: Color invert problem
« Reply #1 on: January 31, 2010, 11:37:45 PM »
I assume you want a scaled version of the inverse colour.  For example, you might want the shadow to be at least in the 0-128 range and not in the 0-255 range? Which would obviously just divide by 2. Do you want the divisor to be scaled as well depending on the brightness of the original colour?

EDIT: Oops just reread your post, ignore this.  
So you want the complementary colour not the inverse?

Complement changes each component of a color to a new value based on the sum of the highest and lowest RGB values in the selected color.

Add the lowest and highest RGB values of the current color, and then subtract the value of each component from that number to create new RGB values.

For example, suppose you select a color with an RGB value of 102 for red, 153 for green, and 51 for blue. Add the high (153) and low (51) values, to end up with a new value (204). Each of the RGB values in the existing color is subtracted from the new value to create new complementary RGB values: 204 – 102 (the current red value) = 102 for the new red value, 204 – 153 (green) = 51 for the new green value, and 204 – 51 (blue) = 153 for the new blue value.

« Last Edit: January 31, 2010, 11:54:17 PM by corremn »
corremn's Roguelikes. To admit defeat is to blaspheme against the Emperor.  Warhammer 40000 the Roguelike

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Color invert problem
« Reply #2 on: February 01, 2010, 09:38:46 AM »
Using that algorithm and dividing the result by 3 for each component I got the proper result. Thanks.

HaileyZwang

  • Newcomer
  • Posts: 1
  • Karma: +0/-0
    • View Profile
    • Email
Re: Color invert problem
« Reply #3 on: May 25, 2011, 11:21:24 AM »
Gone through the tutorial but my connection making some problem I will check this once more.

corremn

  • Rogueliker
  • ***
  • Posts: 700
  • Karma: +0/-0
  • SewerJack Extraordinaire
    • View Profile
    • Demise RogueLike Games
Re: Color invert problem
« Reply #4 on: May 25, 2011, 02:12:49 PM »
Aren't spam bots supposed to make sense now-a-days?
corremn's Roguelikes. To admit defeat is to blaspheme against the Emperor.  Warhammer 40000 the Roguelike