Selection coloring algorithm

I am trying to create a color that can highlight an element as "selected" depending on the color of the current object. I tried to increase some HSB values, but I cannot come up with a generalized formula. In particular, I have problems working with white (bright white does not differ much from ordinary white). There is no requirement that says I need to make it brighter, so some kind of “reverse” color will work too. Are there any standard algorithms or methods for doing something like this (I suppose yes, but I couldn't find any - I'm not sure if there is a name there)?

thanks,

Jeff

+5
source share
4 answers

, negatif:

:

int red = originalColor.red
int green = originalColor.green
int blue = originalColor.blue

int newRed = 255 - red
int newGreen = 255 - green
int newBlue = 255 - blue

Color negativeColor = new Color(newRed, newGreen, newBlue)

:

int red = originalColor.red
int green = originalColor.green
int blue = originalColor.blue

int newRed = 255 - red
int newGreen = 255 - green
int newBlue = 255 - blue + 100
if newBlue > 255 {
   newBlue = 255
   newRed = newRed - 50
   newGreen = newGreen - 50
   if newRed < 0 {newRed = 0}
   if newGreen < 0 {newGreen = 0}
}

Color negativeColor = new Color(newRed, newGreen, newBlue)
+3

, , - () . , .

alt text
(: wordpress.com)

( ), . DarkBlue-on-LightBlue LightBlue-on-DarkBlue. , .

+3

HSB, , "" ( ). , , , .

, , "", . "" , -, -.

( ?), , , .

+3
source

You can find tools at http://www.easyrgb.com/ to give you some ideas.

0
source

All Articles