Jump to content

_PixelSearchinCircle()


quixote79
 Share

Recommended Posts

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