Jump to content



Photo

Yet another clock


  • Please log in to reply
14 replies to this topic

#1 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 19 May 2009 - 04:02 PM

I found another GDI+ clock program so again I set about converting it to AutoIt. I've attached a ZIP with the script and a number of themes that can be used. You can create your own themes by creating PNG files for the dial and the various needles. You also need to specify the coordinates for the centre of the images and put all the information in the clockSettings.ini file.

You'll be pleased to know that this one uses minimal CPU as I'm using WM_TIMER to draw the clock so the main program loop is one big Sleep (one minute at a time). I'd be very interested to see if anyone makes new skins for this.

The full package can be downloaded from HERE

WBD

EDIT: Fixed jumping second hand, included new themes and moved the code to Google

Edited by WideBoyDixon, 20 May 2009 - 01:08 PM.






#2 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 19 May 2009 - 04:15 PM

That is really nice!

#3 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,078 posts

Posted 19 May 2009 - 04:35 PM

Pretty sharp WideBoy!!!

Now to add in the alarm settings... :)

8)

Posted Image

Clic The Pic!!!


#4 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,199 posts

Posted 19 May 2009 - 04:39 PM

I found another GDI+ clock program so again I set about converting it to AutoIt. I've attached a ZIP with the script and a number of themes that can be used. You can create your own themes by creating PNG files for the dial and the various needles. You also need to specify the coordinates for the centre of the images and put all the information in the clockSettings.ini file.

You'll be pleased to know that this one uses minimal CPU as I'm using WM_TIMER to draw the clock so the main program loop is one big Sleep (one minute at a time). I'd be very interested to see if anyone makes new skins for this.

[attachment=26264:clock2.zip]

WBD

It lovely!
One small thing though, the centre of the clock jumps up and down when the second hand comes round to the 6.

Edited by martin, 19 May 2009 - 04:39 PM.

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.

#5 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 19 May 2009 - 05:13 PM

I know about the jumping ... I'll try and investigate. It's got something to do with using GDI+ to rotate the images I think.

Just for fun, I've added a new theme on the first post ... An AutoIt3 clock :)

WBD

#6 youknowwho4eva

youknowwho4eva

    Giggity Giggity Goo

  • Active Members
  • PipPipPipPipPipPip
  • 710 posts

Posted 19 May 2009 - 05:32 PM

The second hand also moves 62 times per revolution. And the minute hand moves when @sec = 0. I'm guessing some of the placement issues are caused by you dividing 0 by a number at certain places.

Edit: I looked through, and can't understand 85% of everything but changing the 3 drawneedle calls to

If @min <> 0 Then
_DrawNeedle($graph, $hourNeedle, $aH[0], $aH[1], @HOUR * 30 + (@MIN / 2))
Else
_DrawNeedle($graph, $hourNeedle, $aH[0], $aH[1], @HOUR * 30)
EndIf

If @sec <> 0 Then
_DrawNeedle($graph, $minuteNeedle, $aM[0], $aM[1], @MIN * 6 + (@SEC / 10))
Else
_DrawNeedle($graph, $minuteNeedle, $aM[0], $aM[1], @MIN * 6)
EndIf

_DrawNeedle($graph, $secondNeedle, $aS[0], $aS[1], @SEC * 6)
seems to fix the @sec = 0 and probably the rarer @min = 0 that I haven't ran it long enough to see.

Edited by youknowwho4eva, 19 May 2009 - 05:43 PM.

Giggity

#7 mesale0077

mesale0077

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 347 posts

Posted 19 May 2009 - 05:56 PM

very nice

#8 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 19 May 2009 - 10:17 PM

If @min <> 0 Then
_DrawNeedle($graph, $hourNeedle, $aH[0], $aH[1], @HOUR * 30 + (@MIN / 2))
Else
_DrawNeedle($graph, $hourNeedle, $aH[0], $aH[1], @HOUR * 30)
EndIf

If @sec <> 0 Then
_DrawNeedle($graph, $minuteNeedle, $aM[0], $aM[1], @MIN * 6 + (@SEC / 10))
Else
_DrawNeedle($graph, $minuteNeedle, $aM[0], $aM[1], @MIN * 6)
EndIf

Totally unnecessary? If @MIN = 0 Then @MIN / 2 = 0. That's not divide BY zero; it's dividing zero by 2 or 10. The above won't make any difference. I experimented with the following replacement for _DrawNeedle():

Func _DrawNeedle($graph, $pNeedle, $nNeedleCenterX, $nNeedleCenterY, $rAngle)     Local $status = DllCall($ghGDIPDll, "int", "GdipRotateWorldTransform", "hwnd", $graph, "float", $rAngle, "int", 1)     $status = DllCall($ghGDIPDll, "int", "GdipTranslateWorldTransform", "hwnd", $graph, "float", $aD[0], "float", $aD[1], "int", 1)     _GDIPlus_GraphicsDrawImageRect($graph, $pNeedle, -$nNeedleCenterX - ($rAngle = 180), -$nNeedleCenterY - ($rAngle = 180), _             _GDIPlus_ImageGetWidth($pNeedle), _GDIPlus_ImageGetHeight($pNeedle))     $status = DllCall($ghGDIPDll, "int", "GdipResetWorldTransform", "hwnd", $graph) EndFunc  ;==>_DrawNeedle

That seems to solve the jump but it's not very elegant. I'm not sure why GDI+ is getting the rotation wrong :-/

WBD

#9 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 20 May 2009 - 11:22 AM

Just for fun, I created another theme for this. It's my first stab at emulating a Mickey Mouse watch. See first post.

:)

WBD

EDIT: Removed attachment and moved code to Google.

Edited by WideBoyDixon, 20 May 2009 - 01:09 PM.


#10 GreenCan

GreenCan

    Polymath

  • Active Members
  • PipPipPipPip
  • 238 posts

Posted 09 July 2009 - 07:12 PM

@WideBoyDixon,

A bit late for a reaction but anyhow...
congrats with your GDI clock, well done

GreenCan

#11 yehia

yehia

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 274 posts

Posted 09 July 2009 - 07:43 PM

i like it so much but i was wondering
how did u draw the pngs of alarm and the normal clock both r awesome
i mean the light reflections and the shadow after the alarm

#12 Info

Info

    :D

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 09 July 2009 - 08:47 PM

Nice :)

I'm having a hard time with that clock, perhaps make an option to change it to a digital cloak?

#13 WideBoyDixon

WideBoyDixon

    Code Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 381 posts

Posted 09 July 2009 - 10:21 PM

i like it so much but i was wondering
how did u draw the pngs of alarm and the normal clock both r awesome
i mean the light reflections and the shadow after the alarm


I didn't draw them. I took them from the original code that I converted.

Nice :)

I'm having a hard time with that clock, perhaps make an option to change it to a digital cloak?


That would kinda delete the purpose of using GDI+ to rotate the hands of the clock.

WBD

#14 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 10 July 2009 - 12:50 AM

Nice Clock! I like the ability to change the themes.
"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#15 netxfly

netxfly

    Seeker

  • New Members
  • 1 posts

Posted 10 July 2009 - 03:56 AM

oh,my god, so big a clock!
very nice, keep up!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users