Jump to content

Func _PixelSearchCircumference($centerX, $centerY, $radius, $color)


sphexion
 Share

Recommended Posts

This is my first edition of the function. Lots can be don from just this.

What it does it scans in a Circumference. Aka a circle around as designated.
I wanted a optimized way of pixel searching and came up with this to be the best preforming.

Local Const $180_div_pi = 180 / ACos(-1)

$it = _PixelSearchCircumference(194, 762, 160, 0xFA3C32)
MouseMove($it[1],$it[2],0)
Sleep(5000)

Func _Angle($tX, $tY, $cX, $cY)
    $mx = $tX - $cX
    $my = $cY - $tY
    $angle = ATan($my / $mx) * $180_div_pi
    If $mx < 0 Then
        $angle = 180 + $angle
    ElseIf $mx >= 0 And $my < 0 Then
        $angle = 360 + $angle
    EndIf
    Return Int($angle)
EndFunc   ;==>_Angle

Func Angle($X1, $Y1, $Ang, $Length)
    Local $Return[3]
    $Return[1] = $X1 + ($Length * Cos($Ang / 180 * 3.14159265358979))
    $Return[2] = $Y1 - ($Length * Sin($Ang / 180 * 3.14159265358979))
    Return $Return
EndFunc   ;==>Angle

Func _PixelSearchCircumference($centerX, $centerY, $radius, $color)
For $i = 0 To 360 Step +1
$rod = Angle($centerX,$centerY, $angle, $radius)
$iColor = PixelGetColor($rod[1] , $rod[2])
If $iColor == $color Then
Return $rod
ExitLoop
EndIf
Next
EndFunc
Link to comment
Share on other sites

A full radar system can be designed.
Scan center out at degrees then +1 degree scan out loop

Optimal designs would be scan _PixelSearchCircumference()
Followed up with scan from center out at 0, 90 , 180 ,270 degree

This would be the best preforming for a movement to keep tabs on radar.
Full pixel region scans will bog system calculations down, esp while rendering video.

Edited by sphexion
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...