Sign in to follow this  
Followers 0
sbgwb0769

How to use "for to" to complete this code?

6 posts in this topic

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>


GUICreate("", 500, 500, -1, -1)

GUICtrlCreateGraphic(0, 0, 500, 500)

For $i = 0 To 12
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 250, 250, 200, 90 + ($i * 30), 30)
Next

iconone()

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func iconone()
    GUICtrlCreateButton("", 500 / 2 - 40 / 2, 500 / 2 - 40 / 2, 40, 40)
    GUICtrlCreateButton("", 500 / 2 - 40 / 2 - 200, 500 / 2 - 40 / 2, 40, 40)
    GUICtrlCreateButton("", 500 / 2 - 40 / 2 - 200 + 30, 500 / 2 - 40 / 2 + 90, 40, 40)
    GUICtrlCreateButton("", 500 / 2 - 40 / 2 - 200 + 30 + 60, 500 / 2 - 40 / 2 + 90 + 80, 40, 40)
    GUICtrlCreateButton("", 500 / 2 - 40 / 2 - 200 + 30 + 60 + 110, 500 / 2 - 40 / 2 + 90 + 110, 40, 40)
;How to use "for to" to complete this code???
EndFunc

;How to use "for to" to complete this code???

post-33165-1232069371_thumb.jpg

Share this post


Link to post
Share on other sites



help me~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

Its a matter of working out the pattern more then anything else. The type of loop you use does not matter.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

I just want to know how to count in this round, with automatic algorithm with button

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

Global $iCenterX = 250
Global $iCenterY = 250
Global $iRadius = 200
Global $iSpokes = 12
Global $iAngleOffset = 360/$iSpokes


GUICreate("", 500, 500, -1, -1)

GUICtrlCreateGraphic(0, 0, 500, 500)

For $i = 0 To $iSpokes - 1
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, $iCenterX, $iCenterY, $iRadius, ($i * $iAngleOffset), $iAngleOffset)
Next

iconone($iCenterX, $iCenterY, $iRadius, $iSpokes)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func iconone($iCenterX, $iCenterY, $iRadius, $iSpokes, $iSize = 40)
    Local $iOffset = -$iSize/2
    Local $iAngleOffsetRad = (2 * 3.14159) / $iSpokes

    $iCenterX += $iOffset
    $iCenterY += $iOffset

    GUICtrlCreateButton("", $iCenterX, $iCenterY, $iSize, $iSize)
    For $i = 0 To $iSpokes - 1
        GUICtrlCreateButton("", $iCenterX + $iRadius * Cos($i * $iAngleOffsetRad), $iCenterY + $iRadius * Sin($i * $iAngleOffsetRad), $iSize, $iSize)
    Next
EndFunc

The automatic angle calculation isn't that exact unless you choose the number of wheel spokes to be a number that perfectly divides 360.

(And this pattern isn't exactly simple to grasp unless you have a working understanding of trigonometry)

Aside: You get nice patterns when you increase $iSpokes :)

Edited by -Ultima-

[ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]

Share this post


Link to post
Share on other sites

thank you! thank you! i love you!

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