Looking for Help with Colors

Keo_74
01-29-2001, 05:27 PM
I have code that will Randomaly choose a long RGB color.

This color is being used for a Fore property RichText box.

The background for the RTB is Black.

I am trying to find a method to filter out the darker Colors so that only the Brighter ones will be choosen, so that is shows up on the Black Background.

My random RGB color creature can be modified so not a problem. Problem is figuring out how to do it.

I thought one possiblity would be to get the Luminence of the Color and then Reject anything with a low Lum.

Only problem is I can't find how to Calculate Lum.

I appreciate any help you can give me.

PWNettle
02-01-2001, 09:14 AM
RGB colors are based on red, green, and blue values from 0 to 255 with the values closer to 0 being darker and (0, 0, 0) being black. One way to generate random colors for vb objects is to use the RGB function like so:
<PRE> object.ForeColor = RGB(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))</PRE>If you wanted to limit the values to create lighter values you can try something like:<PRE> object.ForeColor = RGB(Int(Rnd * 128) + 128, Int(Rnd * 128) + 128, Int(Rnd * 128) + 128)</PRE>Or:
<PRE> object.ForeColor = RGB(Int(Rnd * 192) + 64, Int(Rnd * 192) + 64, Int(Rnd * 192) + 64)</PRE>I've use this techniques for random web colors and it seemed to work well.

Paul

PS - Sorry if this reply sounds a little whacked...I have a cold/sinus thing going on and I'm more than slightly out of it. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum