DefinedV Posted March 30, 2010 Share Posted March 30, 2010 (edited) Hello, I was wondering if there was a simple way of comparing two hex values with regard to 2 shades of variation. Also is there a way to check if a color is darker than another? i.e if $color1hex == $color2hex , however instead of a direct match, it takes into account 2 shades of variation. -Thank you Edited March 30, 2010 by DefinedV Link to comment Share on other sites More sharing options...
JohnOne Posted March 31, 2010 Share Posted March 31, 2010 I dont know how to answer your question sorry. But (and forgive me if i'm wrong) == is used to compare strings as an exact match (case sensitive) Just for reference. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
DefinedV Posted March 31, 2010 Author Share Posted March 31, 2010 Sorry, I apologize if I came across as unclear. But let me clarify; the PixelGetColor function returns a hex value, but I would like to account for color variation, 2 shades in this case. I would like to compare the value with a previous value I retrieved and if it's within 2 shades of each other, than return true, otherwise return false. Thanks Link to comment Share on other sites More sharing options...
omikron48 Posted March 31, 2010 Share Posted March 31, 2010 I'd guess you'd need to define a function for that one. Can't help you here because I don't know how to quantify what "within 2 shades" means? The hex value return would be RGB values, I'd assume, but I have no idea what calculation you'd need to say that one color is within two shades of another. Link to comment Share on other sites More sharing options...
JohnOne Posted March 31, 2010 Share Posted March 31, 2010 If it means anything, The helpfile says Pixelgetcolor returns a decimal value. From experience I know you can compare it to a hex and get a correct result, but I too dont know enough about colours to work out which wold be darker. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jchd Posted March 31, 2010 Share Posted March 31, 2010 You probably need to do a little search about color matching to define your own appreciation of what you're ready to consider "close enough" for your needs.Anyway and as just stated, colors you read are RGB values which, for elementary practice, can bee seen as a tridimensionnal space with coordinates bounded in [0..255], which is the so-called color-cube.The simplest way to estimate how close are two points in N-space is to compute their (Euclidean) distance. In your case, N=3 and if your pixels' colors, once split in Red, Green and Blue components, are:Local $pixel1[3] = [$r1, $g1, $b1]Local $pixel2[3] = [$r2, $g2, $b2]then the "simple" colorimetric distance separing them is:Local $ColorDist = Sqrt(($r2 - $r1) ^ 2 + ($g2 - $g1) ^ 2 + ($b2 - $b1) ^ 2)The smallest result you get, the closest the two colors are. The Sqrt() isn't even meaningful in your case so you can get along without it and without loosing any significance.In RGB space, the higher values are the most intense: black is {0, 0, 0} white is {255, 255, 255}.There are a large number of ways to appreciate and quantitize colors, but RGB is by far the simplest. Danyfirex 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
DefinedV Posted March 31, 2010 Author Share Posted March 31, 2010 (edited) Thanks everyone, really appreciate it. Edited March 31, 2010 by DefinedV Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now