Sign in to follow this  
Followers 0
quixote79

_PixelSearchinCircle()

1 post in this topic

#1 ·  Posted (edited)

Func _PixelSearchinCircle($centerX, $centerY, $radius, $color, $shadevariation = 0, $step = 1)
    If ($centerX - $radius < 0) or ($centerY - $radius < 0) or ($centerX + $radius > @DesktopWidth) or ($centerY + $radius > @DesktopHeight) Then
        SetError(2)
    Else
        Local $xs[ ($radius + 1) * 2], $xe[ ($radius + 1) * 2]
        For $i = -$radius To $radius Step 1
            $xs[$i + $radius] = Round($centerX - Sqrt($radius ^ 2 - $i ^ 2))
            $xe[$i + $radius] = Round($centerX + Sqrt($radius ^ 2 - $i ^ 2))
            $point = PixelSearch($xs[$i + $radius], $centerY + $i, $xe[$i + $radius], $centerY + $i, $color, $shadevariation, $step)
            If Not @error Then
                Return $point
                ExitLoop
            EndIf
        Next
    EndIf
EndFunc  ;==>_PixelSearchinCircle

Syntax is same to PixelSearch(), but if range is invalid, it returns @error=2.

Tell me if you find any problem, plz. ^^

Edited by quixote79

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