Sign in to follow this  
Followers 0
sphexion

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

3 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Somehow the function _Angle rings a bell for me...

;)


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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