Sign in to follow this  
Followers 0
Aceguy

_pixelget new udf [solved]

7 posts in this topic

#1 ·  Posted (edited)

this is it...... not sure if the format is right...

the UDF.

#include-once
#include<Color.au3>


Func _pixelget($hx,$hy,$hclr,$hvar)
    $hget=PixelGetColor($hx,$hy)
    $hrd=_ColorGetRed($hget)
    $hgr=_ColorGetGreen($hget)
    $hbl=_ColorGetBlue($hget)
    
    
    $hrd2=_ColorGetRed($hclr)
    $hgr2=_ColorGetGreen($hclr)
    $hbl2=_ColorGetBlue($hclr)
    
    
    $hrd3=abs($hrd-$hrd2)
    $hgr3=abs($hgr-$hgr2)
    $hbl3=abs($hbl-$hbl2)
    $hres=$hgr3+$hbl3+$hgr3
 

    if $hres <= $hvar Then
        Return 1
    Else
        Return SetError(1,0,0)
    EndIf
EndFunc
Edited by Aceguy

Share this post


Link to post
Share on other sites



Try

if $hres <= $hvar Then
       Return 1
    Else
       Return SetError(1,0,0)
    EndIf

You may also return some data in @extended macro or in output (ByRef array) parameter/s.

Share this post


Link to post
Share on other sites

#include<Color.au3>
$ct = -1
While 1
 $ct += 1
 If _pixelget(710 + $ct, 564, 16752029, 5) Or $ct > 100 Then ExitLoop
WEnd

Func _pixelget($hx,$hy,$hclr,$hvar)
    $hget=PixelGetColor($hx,$hy)
    $hrd=_ColorGetRed($hget)
    $hgr=_ColorGetGreen($hget)
    $hbl=_ColorGetBlue($hget)
    
    $hrd2=_ColorGetRed($hclr)
    $hgr2=_ColorGetGreen($hclr)
    $hbl2=_ColorGetBlue($hclr)
    
    $hrd3=$hrd-$hrd2
    $hgr3=$hgr-$hgr2
    $hbl3=$hbl-$hbl2
    $htmp=$hgr3+$hbl3+$hgr3
    $hres=abs($htmp)
    
    ConsoleWrite("R1 "&$hrd&"  G1 "&$hgr&"   B1 "&$hbl&@lf)
    ConsoleWrite("R2 "&$hrd2&"  G2 "&$hgr2&"   B2 "&$hbl2&@lf)
    ConsoleWrite($hget&" hget"&@lf)
    ConsoleWrite("hres "&$hres&@lf)
 
    if $hres <= $hvar Then
       Return 1
    Else
       Return SetError(1,0,0)
    EndIf
EndFunc

#include<Color.au3>



Dim $a
$ct = -1
While 1
 $ct += 1
 If _pixelget(710 + $ct, 564, 16752029, 5, True, $a) Or $ct > 100 Then ExitLoop
WEnd
If $ct <= 100 Then ConsoleWrite($a)

Func _pixelget($hx,$hy,$hclr,$hvar,$debug,ByRef $debug_data)
    $hget=PixelGetColor($hx,$hy)
    $hrd=_ColorGetRed($hget)
    $hgr=_ColorGetGreen($hget)
    $hbl=_ColorGetBlue($hget)
    
    $hrd2=_ColorGetRed($hclr)
    $hgr2=_ColorGetGreen($hclr)
    $hbl2=_ColorGetBlue($hclr)
    
    $hrd3=$hrd-$hrd2
    $hgr3=$hgr-$hgr2
    $hbl3=$hbl-$hbl2
    $htmp=$hgr3+$hbl3+$hgr3
    $hres=abs($htmp)
    
 If $debug Then
    $debug_data = "R1 "&$hrd&"  G1 "&$hgr&"   B1 "&$hbl&@lf& _
                "R2 "&$hrd2&"  G2 "&$hgr2&"   B2 "&$hbl2&@lf& _
                $hget&" hget"&@lf& _
                "hres "&$hres&@lf
 EndIf
 
    if $hres <= $hvar Then
       Return 1
    Else
       Return SetError(1,0,0)
    EndIf
EndFunc

Share this post


Link to post
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
Sign in to follow this  
Followers 0