Jump to content

Specific Pixel Coord with Shade Variation?


Recommended Posts

  • Moderators

I've asked this question before I believe, but maybe I worded it wrong.

Does this make sense?

If PixelGetColor(555, 25) > 0xFFD100 And PixelGetColor(555, 25) < 0xFFD700 Then

I don't know how to figure the shade variations, but, I thought I saw blindwig or Burrup write a script a while back, on shade variations of a specific color. So if you wanted 100 Hex shades difference from your start it would show it. But I can't seem to find it :) .

I've googled it, but the charts only give a few example shades of each color. Anyone have any ideas on how I could set that up?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Does this make sense?

If PixelGetColor(555, 25) > 0xFFD100 And PixelGetColor(555, 25) < 0xFFD700 Then
What you're trying to achieve makes sense. Personally I would do it this way:

local $shade = pixelGetColor(555, 25)
if ($shade > 0xffd100) and ($shade < 0xffd700) and (mod($shade, 0x100) = 0) then
   ; ...
endIf

I place the pixelGetColor() result into a variable because then it won't be necessary for AutoIt to poll the pixel more than once. The mod() condition ensures that the blue component of the colour is 0, which I assume is the desired behaviour since you appear to be checking for a change in green only.

Link to comment
Share on other sites

  • Moderators

Actually I do have them in variables, I was just posting an example... But I agree totally with that.

Forgive my ignorance on pixel colors.

Question: mod($shade, 0x100) "condition ensures that the blue component of the colour is 0". Is the 0x100 = to 100 shades variations?

Sorry if this is a silly question, but I am trying to understand.

And thanks for the above response!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Question:  mod($shade, 0x100)  "condition ensures that the blue component of the colour is 0".  Is the 0x100 = to 100 shades variations?

The mod() construct literally means 'return the remainder of $shade when divided by 0x100', which basically returns just the blue component. By confirming this to be 0 you can ensure that the test doesn't return true for pixels with some amount of blue.
Link to comment
Share on other sites

  • Moderators

Ok, perfect!

Now I still don't know how to find the difference of variations from 0xFFD700 to 0xEFC708.

Or would it make sense to do:

$shade = PixelSearch(555, 25, 555, 25, 0xFFD700, 20)
If Not @error Then
;do something
Endif

Just need to know what to put the shade-variations at. I have both hex colors.

Edit I'm sorry, I have those 2 specific hex colours. But I usually only have 1 (always different), and need to do the difference between the above (0xEFC708 to 0xFFD700) for every search. So if the colours are 100 shades different, I need to do that for all: 0xFFFFFF + 100 shades = ???

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Now I still don't know how to find the difference of variations from 0xFFD700 to 0xEFC708.

PixelSearch() as you demonstrated may do, but I don't use it and I'm not clear on whether a shade-variation of 20 means something like 'any of the RGB components can deviate by up to 20 units and I will return true'. Obviously if all of the RGB components are 20 off at once then you probably don't want the function to return true.

We could split up the colours into their components and craft an If statement that says:

* If the red component is between 0xEF and 0xFF inclusive, and

* if the green component is between 0xC7 and 0xD7 inclusive, and

* if the blue component is between 0x00 and 0x08 inclusive, then...

#include <Color.au3>

local $pixel = pixelGetColor(555, 25)
local $pixelR = _colorGetRed($pixel)
local $pixelG = _colorGetGreen($pixel)
local $pixelB = _colorGetBlue($pixel)

if ($pixelR >= 0xef) and ($pixelG >= 0xc7 and $pixelG <= 0xd7) and ($pixelB <= 0x08) then
   ; colour is within the range 0xEFC708 to 0xFFD700
   ; and is therefore probably a shade
endIf

Disclaimer: I'm known to come up with dodgy code at 2AM so you can probably expect better from members enjoying daylight! :)

Link to comment
Share on other sites

I don't know how to figure the shade variations, but, I thought I saw blindwig or Burrup write a script a while back, on shade variations of a specific color.  So if you wanted 100 Hex shades difference from your start it would show it.  But I can't seem to find it  :) .

<{POST_SNAPBACK}>

I began to write an 'advanced' PixelSearch() function where you are able to specify a different shade variation for each RGB component of the colour you are search ing for. I never got round to finishing it but I believe it's in the 'Idea Lab' if you want to look at it :evil:.

qq

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...