Jump to content

Recommended Posts

Posted

Greets, been able to find most of my answers by using the search command here on the forums or through the included help file, but this one has me stuck.

What I'm trying to do is have autoit scan the outer edge of a circle. Just the outer edge. I could take the easy way out and have it scan the entire area that the circle includes, but I'm a glutton for punishment :)

I know that AutoIT is capable of doing this, but it's my math knowledge that's proving to be a hindrance. I'm sure there's some formula out there that I need to plug in. Probably something to do with PI and the radius/circumference. Any math majors (or even someone that actually paid attention to highschool geometry) out there able to give me a hand?

Thanks in advance

Posted

Circumference of circle = Pi*Diametre

<{POST_SNAPBACK}>

As I said before, my math teacher is cackling somewhere.

Will work on plugging that in and much thanks.

Posted

Here's a function that draws a circle, you could apply it to scanning:

Func DrawCircle($XCenter, $YCenter, $Radius, $color)
    Local $TempDC = 0
    Local $piX2 = 3.14159*2
    $deltaTheta = 1/$Radius
    Local $pixelCount = _Ceil (($piX2 + $deltaTheta)/$deltaTheta)
    
    Dim $Pixel[$pixelCount][2]
    
    For $pixelIndex = 0 To $pixelCount - 1
        $Pixel[$pixelIndex][0] = $Xcenter + Cos($pixelIndex*$deltaTheta)*$Radius
        $Pixel[$pixelIndex][1] = $Ycenter + Sin($pixelIndex*$deltaTheta)*$Radius
    Next
    
    DCConstructor($TempDC)
    
    SetPixel($TempDC, $Pixel, "", $color)
    
    DCDescructor($TempDC)
EndFunc ;==>DrawCircle

Thread: http://www.autoitscript.com/forum/index.php?showtopic=8831

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Posted

Much thanks Insolence, I've been fighting with this for two days now. Understanding something is the first step to changing it though and right now I'm lost. The part that I'm having trouble following is this:

For $pixelIndex = 0 To $pixelCount - 1
        $Pixel[$pixelIndex][0] = $Xcenter + Cos($pixelIndex*$deltaTheta)*$Radius
        $Pixel[$pixelIndex][1] = $Ycenter + Sin($pixelIndex*$deltaTheta)*$Radius
    Next

Granted I'm new to this, but I've never seen the variables used like this: $Pixel[$PixelIndex]. I've scoured the tutorial, but what exactly is it doing with the variable in brackets? Assigning both variables the same value?

Posted

$Pixel is an array. The variable in brackets defines which element of the array is being looked at.

From the manual:

Dim / Global / Local / Const

--------------------------------------------------------------------------------

Declare a variable, a constant, or create an array.

Dim [Const]$variable

Dim $array[subscript 1]...[subscript n]

Parameters

const [optional] If present, the Const keyword creates a constant rather than a variable.

$variable The name of the variable to declare.

subscript The number of elements to create for the array dimension, indexed 0 to n-1.

Posted

$Pixel is an array.  The variable in brackets defines which element of the array is being looked at.

From the manual:

<{POST_SNAPBACK}>

That explains it, and creates some interesting possibilities. Thanks andrew.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...