Jump to content

How to make a dotted circle with GuiCtrlSetGraphic?


Recommended Posts

I'm trying to make an analog clock with GuiCtrlSetGraphic and I'm trying to get the program to make a circle out of dotted points, but I'm stuck. Any help?

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         JustinReno

 Script Function:
    A simple clock.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIConstants.au3>

Global $Pi = 3.14
Global $Hour

$GUI = GUICreate("Simple Clock", 237, 221)
$Graphic = GUICtrlCreateGraphic(0, 0, 236, 220)
GUISetState(@SW_SHOW, $GUI)

While 1
    GUICtrlSetGraphic($Graphic, $GUI_GR_REFRESH)
    Sleep(10)
    Switch GUIGetMsg()
        Case - 3
            Exit
    EndSwitch
    If @Hour > 10 Then $Hour = @HOUR - 12
    For $I = 1 To 360
        GUICtrlSetGraphic($Graphic, $GUI_GR_DOT, $Pi - $I, $I)
    Next
WEnd
Link to comment
Share on other sites

I'm trying to make an analog clock with GuiCtrlSetGraphic and I'm trying to get the program to make a circle out of dotted points, but I'm stuck. Any help?

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         JustinReno

 Script Function:
    A simple clock.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIConstants.au3>

Global $Pi = 3.14
Global $Hour

$GUI = GUICreate("Simple Clock", 237, 221)
$Graphic = GUICtrlCreateGraphic(0, 0, 236, 220)
GUISetState(@SW_SHOW, $GUI)

While 1
    GUICtrlSetGraphic($Graphic, $GUI_GR_REFRESH)
    Sleep(10)
    Switch GUIGetMsg()
        Case - 3
            Exit
    EndSwitch
    If @Hour > 10 Then $Hour = @HOUR - 12
    For $I = 1 To 360
        GUICtrlSetGraphic($Graphic, $GUI_GR_DOT, $Pi - $I, $I)
    Next
WEnd
cant you just make a circle in paint? and then make the minute / second / hour hands in paint, then position them accordingly?

just an idea

Edited by ReaImDown
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

I'm trying to make an analog clock with GuiCtrlSetGraphic and I'm trying to get the program to make a circle out of dotted points, but I'm stuck. Any help?

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         JustinReno

 Script Function:
    A simple clock.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIConstants.au3>

Global $Pi = 3.14
Global $Hour

$GUI = GUICreate("Simple Clock", 237, 221)
$Graphic = GUICtrlCreateGraphic(0, 0, 236, 220)
GUISetState(@SW_SHOW, $GUI)

While 1
    GUICtrlSetGraphic($Graphic, $GUI_GR_REFRESH)
    Sleep(10)
    Switch GUIGetMsg()
        Case - 3
            Exit
    EndSwitch
    If @Hour > 10 Then $Hour = @HOUR - 12
    For $I = 1 To 360
        GUICtrlSetGraphic($Graphic, $GUI_GR_DOT, $Pi - $I, $I)
    Next
WEnd

You can draw lines, circles or anything with GuiCtrlSetGraphic. Have a look at the help.

Here's a start, not with lines, but it gives an idea.

#include <GUIConstants.au3>
    

$gui=GUICreate("outer ring",440,440)

$a=GuiCtrlCreateGraphic(20, 20, 400,400)
GUICtrlSetBkColor(-1,0xffffff)
GUICtrlSetColor(-1,0)
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0xffffff)

for $arc = 0 to 59
    GUICtrlSetGraphic(-1,$GUI_GR_DOT,200+180*Cos($arc * 3.1459/30)-2,200 + 180*sin($arc * 3.1459/30)-2)
    Next
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0xffbbcc)
$dotdia = 10;actually radius
for $deg = 0 to 11
GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE,200 + (190-$dotdia)*Cos($deg * 3.1459/6)-$dotdia,200- (190-$dotdia)*Sin($deg * 3.1459/6)-$dotdia,2*$dotdia,2*$dotdia)
next

GuiSetState()

while guigetmsg() <> -3
    
WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

You can draw lines, circles or anything with GuiCtrlSetGraphic. Have a look at the help.

Here's a start, not with lines, but it gives an idea.

#include <GUIConstants.au3>
    

$gui=GUICreate("outer ring",440,440)

$a=GuiCtrlCreateGraphic(20, 20, 400,400)
GUICtrlSetBkColor(-1,0xffffff)
GUICtrlSetColor(-1,0)
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0xffffff)

for $arc = 0 to 59
    GUICtrlSetGraphic(-1,$GUI_GR_DOT,200+180*Cos($arc * 3.1459/30)-2,200 + 180*sin($arc * 3.1459/30)-2)
    Next
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0xffbbcc)
$dotdia = 10;actually radius
for $deg = 0 to 11
GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE,200 + (190-$dotdia)*Cos($deg * 3.1459/6)-$dotdia,200- (190-$dotdia)*Sin($deg * 3.1459/6)-$dotdia,2*$dotdia,2*$dotdia)
next

GuiSetState()

while guigetmsg() <> -3
    
WEnd
I like...
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

You can draw lines, circles or anything with GuiCtrlSetGraphic. Have a look at the help.

Here's a start, not with lines, but it gives an idea.

#include <GUIConstants.au3>
    

$gui=GUICreate("outer ring",440,440)

$a=GuiCtrlCreateGraphic(20, 20, 400,400)
GUICtrlSetBkColor(-1,0xffffff)
GUICtrlSetColor(-1,0)
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0xffffff)

for $arc = 0 to 59
    GUICtrlSetGraphic(-1,$GUI_GR_DOT,200+180*Cos($arc * 3.1459/30)-2,200 + 180*sin($arc * 3.1459/30)-2)
    Next
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0xffbbcc)
$dotdia = 10;actually radius
for $deg = 0 to 11
GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE,200 + (190-$dotdia)*Cos($deg * 3.1459/6)-$dotdia,200- (190-$dotdia)*Sin($deg * 3.1459/6)-$dotdia,2*$dotdia,2*$dotdia)
next

GuiSetState()

while guigetmsg() <> -3
    
WEnd
How did you come up with this? Its very cool!
Link to comment
Share on other sites

How did you come up with this? Its very cool!

?? Glad you like it but it's just a doodle to show you drawing things around a circle. I thought I'll put a dot for each minute and a little circle for every 5 minutes and if I draw the 5 minute circles after the little dots then I don't have to worry about missing out every 5th dot. Just took a guess at colours.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...