Jump to content

some sort of a green


Recommended Posts

I am writing a filter script, and I need to define colors to scan for.

As long as it's some sort of a green, it works.

how do I define a spectrum of a green?

Pixelget color lets me know which color it is, and I need to define that as long as it's close enough to it it works.

Link to comment
Share on other sites

#include <Color.au3>

$iGreenColor = _ColorGetGreen( 0x8080ff )
MsgBox( 4096, "AutoIt", $iGreenColor )
I don't know if thats what querty is after, eg consider the colour 0xFFFF00. This is bright yellow and has a green value of 255.

Querty I have been looking on google, but I can't really find anything. You might have to open up a paint pallet and just try your luck at defining the ranges manually.

Dave

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

Link to comment
Share on other sites

I don't know if thats what querty is after, eg consider the colour 0xFFFF00. This is bright yellow and has a green value of 255.

Querty I have been looking on google, but I can't really find anything. You might have to open up a paint pallet and just try your luck at defining the ranges manually.

Dave

Then look at this:

#include <Color.au3>
#include <GUIConstants.au3>

$gui = GUICreate("Rainbow",@DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
$size = WinGetClientSize($gui)
$step = $size[0] / 6

_GUICtrlCreateGradient(0xFF0000, 0xFFFF00, 0*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0xFFFF00, 0x00FF00, 1*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0x00FF00, 0x00FFFF, 2*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0x00FFFF, 0x0000FF, 3*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0x0000FF, 0xFF00FF, 4*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0xFF00FF, 0xFF0000, 5*$step, 0, $step, $size[1])
GUISetCursor(16,1)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
Wend

Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
    Local $color1R = _ColorGetRed($nStartColor)
    Local $color1G = _ColorGetGreen($nStartColor)
    Local $color1B = _ColorGetBlue($nStartColor)

    Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $step
    Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $step
    Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $step

    GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
    For $i = 0 To $nWidth
        $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$i, $color1G+$nStepG*$i, $color1B+$nStepB*$i)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $i, 0)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $i, $nHeight)
    Next
EndFunc
Edited by Zedna
Link to comment
Share on other sites

Then look at this:

#include <Color.au3>
#include <GUIConstants.au3>

$gui = GUICreate("Rainbow",@DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
$size = WinGetClientSize($gui)
$step = $size[0] / 6

_GUICtrlCreateGradient(0xFF0000, 0xFFFF00, 0*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0xFFFF00, 0x00FF00, 1*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0x00FF00, 0x00FFFF, 2*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0x00FFFF, 0x0000FF, 3*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0x0000FF, 0xFF00FF, 4*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0xFF00FF, 0xFF0000, 5*$step, 0, $step, $size[1])
GUISetCursor(16,1)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
Wend

Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
    Local $color1R = _ColorGetRed($nStartColor)
    Local $color1G = _ColorGetGreen($nStartColor)
    Local $color1B = _ColorGetBlue($nStartColor)

    Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $step
    Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $step
    Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $step

    GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
    For $i = 0 To $nWidth
        $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$i, $color1G+$nStepG*$i, $color1B+$nStepB*$i)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $i, 0)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $i, $nHeight)
    Next
EndFunc
That's an impressive gui, but I don't see how that proves 0xFFFF00 is a type of green in the context that querty is after it in?? please explain :)

Dave

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

Link to comment
Share on other sites

In addition to my previous post consider the "RGB Display and CMYK Printing" image on this website:

http://www.answers.com/topic/rgb

Dave

Edited by Davo

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

Link to comment
Share on other sites

in my previous attempts, I tried to to use scripts to record every color I need to scan for, but I found out that at 16bit, RGB actually has about 17 million colors, and that the green is a big chunk of it,

so based on that, I just need a few ranges of color that can be called green.

some sort of a green.

how do I define it?

Link to comment
Share on other sites

Returns true if color is within that gradient range of green.

Func _IsGreen($hex)
    If BitAND($hex,0x0000FF) = 0x00 And BitAND($hex,0x00FF00) = 0x00FF00 Or _ 
        BitAND($hex,0xFF0000) = 0x00 And BitAND($hex,0x00FF00) = 0x00FF00 Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc

MsgBox(0,"0x00ffff",_IsGreen(0x00ffff)) ;true
MsgBox(0,"0x34ff00",_IsGreen(0x34ff00)) ;true
MsgBox(0,"0x00ff65",_IsGreen(0x00ff65)) ;true
MsgBox(0,"0x333333",_IsGreen(0x333333)) ;false
Edited by Toady

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

#include <Color.au3>
#include <GUIConstants.au3>

$gui = GUICreate("Rainbow",@DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
$size = WinGetClientSize($gui)
$step = $size[0] / 6

;~ _GUICtrlCreateGradient(0xFF0000, 0xFFFF00, 0*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0xFFFF00, 0x00FF00, 1*$step, 0, $step, $size[1])
_GUICtrlCreateGradient(0x00FF00, 0x00FFFF, 2*$step, 0, $step, $size[1])
;~ _GUICtrlCreateGradient(0x00FFFF, 0x0000FF, 3*$step, 0, $step, $size[1])
;~ _GUICtrlCreateGradient(0x0000FF, 0xFF00FF, 4*$step, 0, $step, $size[1])
;~ _GUICtrlCreateGradient(0xFF00FF, 0xFF0000, 5*$step, 0, $step, $size[1])
GUISetCursor(16,1)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
Wend

Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
    Local $color1R = _ColorGetRed($nStartColor)
    Local $color1G = _ColorGetGreen($nStartColor)
    Local $color1B = _ColorGetBlue($nStartColor)

    Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $step
    Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $step
    Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $step

    GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
    For $i = 0 To $nWidth
        $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$i, $color1G+$nStepG*$i, $color1B+$nStepB*$i)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $i, 0)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $i, $nHeight)
    Next
EndFunc

Edited by Zedna
Link to comment
Share on other sites

ok I can read the code, but I am not sure about the concept.

every point on the chart is made up of three numbers, RGB,

so it's as easy as using the idea of (x,y) to enclose it.

how did you read the chart to know that the color in within the chart?

Link to comment
Share on other sites

I am writing a filter script, and I need to define colors to scan for.

As long as it's some sort of a green, it works.

how do I define a spectrum of a green?

Pixelget color lets me know which color it is, and I need to define that as long as it's close enough to it it works.

Use PixelSearch() instead, and check out the optional "Shade Variation" parameter. If you pixel search an area of one pixel, you are effectively doing a PixelGetColor() and testing it against the color you are interested in:

PixelSearch(100, 200, 100, 200, 0x00FF00, 50) ; Tweak last parameter for sensitivity
If @error Then
    MsgBox(16, "Color Test", "Pixel at (100, 200) is not a shade of green.")
Else
    MsgBox(64, "Color Test", "Pixel at (100, 200) is a shade of green.")
EndIf

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Did you see my post I put with the function to see if a color is a green?

try the color 0xFFFF00, its definately not green :)

querty, I am pretty sure the only way to do what you are trying to do is to guess where the colour ranges of green lie. An approximation I have got for you is that the red and blue component should never be greater then 200-215 and the green component should stay at 255. Using this method should give u quite a large range of greens, aswell as avoiding the extreme values of the green color (according to the computer) such as 255,255,0 and 0,255,255 which give the colours yellow and cyan, respectively. :)

Keep in mind I am just using approximations and someone else might come along and say that 210,255,210 isn't green, well tough titties, its closer to green then 255,255,0 or 0,255,255 :)

Dave

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

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...