A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

How do you determine what color matches another?

921 views · started by GAMEchief ·
#1
How do you determine what color matches another?
Say I throw out a random color like #3080c0. What color matches it such that the two together look good? e.g. What's a good background color to #3080c0 as a foreground color?
#2
like color schemes?
#3
I'm possibly looking for complimentary, but that site's complimentary uses 5 colors, and it doesn't quite tell how it's generated. Is the hue just shifted by like 90 or 180 or whatever it is?
#4
GAMEchief wrote:
I'm possibly looking for complimentary, but that site's complimentary uses 5 colors, and it doesn't quite tell how it's generated. Is the hue just shifted by like 90 or 180 or whatever it is?


complimentary is across the color wheel so 180
#5
I did some research and this was a snippet i found.


<?PHP

FUNCTION inverseHex( $color )
{
$color = TRIM($color);
$prependHash = FALSE;

IF(STRPOS($color,'#')!==FALSE) {
$prependHash = TRUE;
$color = STR_REPLACE('#',NULL,$color);
}

SWITCH($len=STRLEN($color)) {
CASE 3:
$color=PREG_REPLACE("/(.)(.)(.)/","\\1\\1\\2\\2\\3\\3",$color);
CASE 6:
BREAK;
DEFAULT:
TRIGGER_ERROR("Invalid hex length ($len). Must be (3) or (6)", E_USER_ERROR);
}

IF(!PREG_MATCH('/[a-f0-9]{6}/i',$color)) {
$color = HTMLENTITIES($color);
TRIGGER_ERROR( "Invalid hex string #$color", E_USER_ERROR );
}

$r = DECHEX(255-HEXDEC(SUBSTR($color,0,2)));
$r = (STRLEN($r)>1)?$r:'0'.$r;
$g = DECHEX(255-HEXDEC(SUBSTR($color,2,2)));
$g = (STRLEN($g)>1)?$g:'0'.$g;
$b = DECHEX(255-HEXDEC(SUBSTR($color,4,2)));
$b = (STRLEN($b)>1)?$b:'0'.$b;

RETURN ($prependHash?'#':NULL).$r.$g.$b;
}

// Demo
// echo inverseHex('#000000'); // #ffffff
?>


Hope this helps ya chief
#6
da fuck is inverse. 180 away on the color wheel?
#7
GAMEchief wrote:
da fuck is inverse. 180 away on the color wheel?


ya right across
like orange - blue
red - green
purple - yellow
#8
What about lightness? Wouldn't you reverse it? I assume that'd just be the absolute value of 255 minus the original color's lightness.

ugh i wanted to use rgb for the math, not hsl :(
#9
idk #'s man
y u gotta make it about numbers
#10
Writing algorithms mang.