qwertylol Posted May 20, 2007 Share Posted May 20, 2007 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 More sharing options...
Zedna Posted May 20, 2007 Share Posted May 20, 2007 #include <Color.au3> $iGreenColor = _ColorGetGreen( 0x8080ff ) MsgBox( 4096, "AutoIt", $iGreenColor ) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Davo Posted May 20, 2007 Share Posted May 20, 2007 #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 More sharing options...
Zedna Posted May 20, 2007 Share Posted May 20, 2007 (edited) 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: expandcollapse popup#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 May 20, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Davo Posted May 20, 2007 Share Posted May 20, 2007 Then look at this: expandcollapse popup#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 More sharing options...
Davo Posted May 20, 2007 Share Posted May 20, 2007 (edited) In addition to my previous post consider the "RGB Display and CMYK Printing" image on this website:http://www.answers.com/topic/rgbDave Edited May 20, 2007 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 More sharing options...
qwertylol Posted May 20, 2007 Author Share Posted May 20, 2007 this pic should explain what I need. I need to understand how color in decimal ( or if it has to be, hex) is made up of I need to define that region of green, plus brightness.color_chart.bmp Link to comment Share on other sites More sharing options...
qwertylol Posted May 20, 2007 Author Share Posted May 20, 2007 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 More sharing options...
qwertylol Posted May 20, 2007 Author Share Posted May 20, 2007 (edited) like this Edited May 20, 2007 by qwertylol Link to comment Share on other sites More sharing options...
Toady Posted May 20, 2007 Share Posted May 20, 2007 (edited) 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 May 20, 2007 by Toady www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
Zedna Posted May 20, 2007 Share Posted May 20, 2007 (edited) expandcollapse popup#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 May 20, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
qwertylol Posted May 20, 2007 Author Share Posted May 20, 2007 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 More sharing options...
qwertylol Posted May 20, 2007 Author Share Posted May 20, 2007 aside from the seemingly complete enclosed area, there are actually a but more options to creat "some sort of a green" Link to comment Share on other sites More sharing options...
qwertylol Posted May 20, 2007 Author Share Posted May 20, 2007 how did your guys figure out how to read the chart? RGB. Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 20, 2007 Share Posted May 20, 2007 (edited) 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 May 20, 2007 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 More sharing options...
Toady Posted May 21, 2007 Share Posted May 21, 2007 Did you see my post I put with the function to see if a color is a green? www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding Link to comment Share on other sites More sharing options...
Davo Posted May 21, 2007 Share Posted May 21, 2007 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 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