Jump to content
Sign in to follow this  
AcidCorps

Setting numbers in an analog clock

Recommended Posts

AcidCorps

I'm working on a script for an alarm clock using many existing examples from the forum but I came across a problem, right now I'm trying to place the 1, 2, 3, 4... 12, in the appropriate places inside the clock but can't figure out how to make them the right place, I know I saw an example where someone used sin or cos but I can't find it again and I don't remember my math good enough to figure out how to myself, if anyone can point me in the right direction I'd appreciate it.

Here's my script so far (mostly nonfunctional)

CODE

#include <GuiConstants.au3>

#include <StaticConstants.au3>

#include <Date.au3>

Opt("GUIOnEventMode", 1)

Global $GuiTitle = 'LacWare Alarm Clock (Beta)'

Global $AnalogBackgroundColor = IniRead('Data.ini','Color','AnalogBackground', 0xFFFFFF)

Global $AnalogBorderColor = IniRead('Data.ini','Color','AnalogBorder', 0x000000)

Global $AnalogNumberColor = IniRead('Data.ini','Color','AnalogNumber', 0x000000)

Global $DigitalClockColor = IniRead('Data.ini','Color','DigitalClock', 0x0000FF)

Global $DateColor = IniRead('Data.ini', 'Color', 'Date', 0x0000FF)

Global $Hour = @HOUR

Global $Min = @MIN

Global $Sec = @SEC

Global $Date = _NowDate()

Global $Exit = False

Dim $Numbers[12]

;Create GUI

$Gui = GuiCreate($GuiTitle, 400, 250, -1, -1)

GuiCtrlCreateLabel('', 200, 0, 3, 250, $SS_SUNKEN)

;Create Graphics

$AnalogBackground= GUICtrlCreateGraphic(0, 0, 0, 0)

$AnalogBorder = GuiCtrlCreateGraphic(0, 0, 0, 0)

$DigitalClock = GuiCtrlCreateLabel($Hour & ':' & $Min & ':' & $Sec, 15, 175, 150, 35, $SS_CENTER)

$GuiDate = GuiCtrlCreateLabel($Date, 15, 220, 150, 35, $SS_CENTER)

;Create Labesl

$TodaysAlarmsLabel = GuiCtrlCreateLabel("Today's Alarms:", 210, 10, 180, 25, $SS_CENTER)

;CreateButton

$AddAlarm = GuiCtrlCreateButton('Add Alarm', 210, 175, 180, 20)

$ViewAlarms = GuiCtrlCreateButton('View Alarms', 210, 200, 180, 20)

$ViewCalendar = GuiCtrlCreateButton('View Calendar', 210, 225, 180, 20)

;Set Properties

GUICtrlSetGraphic($AnalogBackground,$GUI_GR_COLOR, $AnalogBackgroundColor, $AnalogBackgroundColor)

GUICtrlSetGraphic($AnalogBackground,$GUI_GR_ELLIPSE, 15,15, 150,150)

GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_PENSIZE, 2)

GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_COLOR, $AnalogBorderColor)

GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_NOBKCOLOR)

GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_ELLIPSE, 15, 15, 150, 150)

GuiCtrlSetFont($DigitalClock, 30)

GuiCtrlSetColor($DigitalClock, $DigitalClockColor)

GuiCtrlSetFont($TodaysAlarmsLabel, 15, 400, 4)

GuiCtrlSetFont($GuiDate, 20)

GuiCtrlSetColor($GuiDate, $DateColor)

;Event

GuiSetOnEvent($Gui_Event_Close, '_Exit')

GuiSetOnEvent($Gui_Event_Minimize, '_Minimize')

GuiSetState()

while 1

$Msg = GuiGetMsg()

$Hour = @HOUR

$Min = @MIN

$Sec = @SEC

$Date = _NowDate()

GuiCtrlSetData($DigitalClock, $Hour & ':' & $Min & ':' & $Sec)

GuiCtrlSetData($GuiDate, $Date)

Sleep(250)

WEnd

Func _Exit()

Exit

EndFunc

Func _Minimize()

GuiSetState(@SW_MINIMIZE)

EndFunc

Share this post


Link to post
Share on other sites
martin

I'm working on a script for an alarm clock using many existing examples from the forum but I came across a problem, right now I'm trying to place the 1, 2, 3, 4... 12, in the appropriate places inside the clock but can't figure out how to make them the right place, I know I saw an example where someone used sin or cos but I can't find it again and I don't remember my math good enough to figure out how to myself, if anyone can point me in the right direction I'd appreciate it.

Here's my script so far (mostly nonfunctional)

CODE

#include <GuiConstants.au3>

#include <StaticConstants.au3>

#include <Date.au3>

Opt("GUIOnEventMode", 1)

Global $GuiTitle = 'LacWare Alarm Clock (Beta)'

Global $AnalogBackgroundColor = IniRead('Data.ini','Color','AnalogBackground', 0xFFFFFF)

Global $AnalogBorderColor = IniRead('Data.ini','Color','AnalogBorder', 0x000000)

Global $AnalogNumberColor = IniRead('Data.ini','Color','AnalogNumber', 0x000000)

Global $DigitalClockColor = IniRead('Data.ini','Color','DigitalClock', 0x0000FF)

Global $DateColor = IniRead('Data.ini', 'Color', 'Date', 0x0000FF)

Global $Hour = @HOUR

Global $Min = @MIN

Global $Sec = @SEC

Global $Date = _NowDate()

Global $Exit = False

Dim $Numbers[12]

;Create GUI

$Gui = GuiCreate($GuiTitle, 400, 250, -1, -1)

GuiCtrlCreateLabel('', 200, 0, 3, 250, $SS_SUNKEN)

;Create Graphics

$AnalogBackground= GUICtrlCreateGraphic(0, 0, 0, 0)

$AnalogBorder = GuiCtrlCreateGraphic(0, 0, 0, 0)

$DigitalClock = GuiCtrlCreateLabel($Hour & ':' & $Min & ':' & $Sec, 15, 175, 150, 35, $SS_CENTER)

$GuiDate = GuiCtrlCreateLabel($Date, 15, 220, 150, 35, $SS_CENTER)

;Create Labesl

$TodaysAlarmsLabel = GuiCtrlCreateLabel("Today's Alarms:", 210, 10, 180, 25, $SS_CENTER)

;CreateButton

$AddAlarm = GuiCtrlCreateButton('Add Alarm', 210, 175, 180, 20)

$ViewAlarms = GuiCtrlCreateButton('View Alarms', 210, 200, 180, 20)

$ViewCalendar = GuiCtrlCreateButton('View Calendar', 210, 225, 180, 20)

;Set Properties

GUICtrlSetGraphic($AnalogBackground,$GUI_GR_COLOR, $AnalogBackgroundColor, $AnalogBackgroundColor)

GUICtrlSetGraphic($AnalogBackground,$GUI_GR_ELLIPSE, 15,15, 150,150)

GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_PENSIZE, 2)

GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_COLOR, $AnalogBorderColor)

GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_NOBKCOLOR)

GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_ELLIPSE, 15, 15, 150, 150)

GuiCtrlSetFont($DigitalClock, 30)

GuiCtrlSetColor($DigitalClock, $DigitalClockColor)

GuiCtrlSetFont($TodaysAlarmsLabel, 15, 400, 4)

GuiCtrlSetFont($GuiDate, 20)

GuiCtrlSetColor($GuiDate, $DateColor)

;Event

GuiSetOnEvent($Gui_Event_Close, '_Exit')

GuiSetOnEvent($Gui_Event_Minimize, '_Minimize')

GuiSetState()

while 1

$Msg = GuiGetMsg()

$Hour = @HOUR

$Min = @MIN

$Sec = @SEC

$Date = _NowDate()

GuiCtrlSetData($DigitalClock, $Hour & ':' & $Min & ':' & $Sec)

GuiCtrlSetData($GuiDate, $Date)

Sleep(250)

WEnd

Func _Exit()

Exit

EndFunc

Func _Minimize()

GuiSetState(@SW_MINIMIZE)

EndFunc

Maybe a bit like this

#include <GuiConstants.au3>
#include <StaticConstants.au3>
#include <Date.au3>
Opt("GUIOnEventMode", 1)

Global $GuiTitle = 'LacWare Alarm Clock (Beta)'
Global $AnalogBackgroundColor = IniRead('Data.ini','Color','AnalogBackground', 0xFFFFFF)
Global $AnalogBorderColor = IniRead('Data.ini','Color','AnalogBorder', 0x000000)
Global $AnalogNumberColor = IniRead('Data.ini','Color','AnalogNumber', 0x000000)
Global $DigitalClockColor = IniRead('Data.ini','Color','DigitalClock', 0x0000FF)
Global $DateColor = IniRead('Data.ini', 'Color', 'Date', 0x0000FF)
Global $Hour = @HOUR
Global $Min = @MIN
Global $Sec = @SEC
Global $Date = _NowDate()
Global $Exit = False
Dim $Numbers[12]

;Create GUI
$Gui = GuiCreate($GuiTitle, 400, 250, -1, -1)
GuiCtrlCreateLabel('', 200, 0, 3, 250, $SS_SUNKEN)

;Create Graphics
$AnalogBackground= GUICtrlCreateGraphic(0, 0, 0, 0)
$AnalogBorder = GuiCtrlCreateGraphic(0, 0, 0, 0)
$DigitalClock = GuiCtrlCreateLabel($Hour & ':' & $Min & ':' & $Sec, 15, 175, 155, 38, $SS_CENTER)
$GuiDate = GuiCtrlCreateLabel($Date, 15, 220, 150, 35, $SS_CENTER)

;Create Labesl
$TodaysAlarmsLabel = GuiCtrlCreateLabel("Today's Alarms:", 210, 10, 180, 25, $SS_CENTER)

;CreateButton
$AddAlarm = GuiCtrlCreateButton('Add Alarm', 210, 175, 180, 20)
$ViewAlarms = GuiCtrlCreateButton('View Alarms', 210, 200, 180, 20)
$ViewCalendar = GuiCtrlCreateButton('View Calendar', 210, 225, 180, 20)

;Set Properties
GUICtrlSetGraphic($AnalogBackground,$GUI_GR_COLOR, $AnalogBackgroundColor, $AnalogBackgroundColor)
GUICtrlSetGraphic($AnalogBackground,$GUI_GR_ELLIPSE, 15,15, 151,151)
$rad=65
$cx=82
$cy=82
$ang = 3.14159/6
for $n = 1 to 12
GUICtrlCreateLabel($n,$cx+$rad*cos($ang*$n-3.14159/2)+4,$cy+$rad*sin($ang*$n-3.14159/2)+2)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
Next

GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_PENSIZE, 2)
GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_COLOR, $AnalogBorderColor)
GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_NOBKCOLOR)
GuiCtrlSetGraphic($AnalogBorder, $GUI_GR_ELLIPSE, 15, 15, 150, 150)
GuiCtrlSetFont($DigitalClock, 30)
GuiCtrlSetColor($DigitalClock, $DigitalClockColor)
GuiCtrlSetFont($TodaysAlarmsLabel, 15, 400, 4)
GuiCtrlSetFont($GuiDate, 20)
GuiCtrlSetColor($GuiDate, $DateColor)

;Event
GuiSetOnEvent($Gui_Event_Close, '_Exit')
GuiSetOnEvent($Gui_Event_Minimize, '_Minimize')

GuiSetState()
while 1
$Msg = GuiGetMsg()
$Hour = @HOUR
$Min = @MIN
$Sec = @SEC
$Date = _NowDate()
GuiCtrlSetData($DigitalClock, $Hour & ':' & $Min & ':' & $Sec)
GuiCtrlSetData($GuiDate, $Date)
Sleep(250)
WEnd




Func _Exit()
Exit
EndFunc

Func _Minimize()
GuiSetState(@SW_MINIMIZE)
EndFunc
Edited by martin

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.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.