Main index > About new desklets > Analogue Clock adesklet

By jonmack (User), on Wed Mar 9 21:38:04 2005: Analogue Clock adesklet.

Hi there,

First of all, let me just say how great I think adesklets is! I was so intruiged by it, I sat down tonight and started learning python for the first time. I'm getting there slowly :)

I thought I'd have a go at an analogue clock, since I always wanted one, and other desklet applications require way too many dependencies for my liking. And since I admire the aims of this project, I would like to help out in getting it off its feet.

I'll upload my stuff so far to this link ( hope it works, try the old renaming trick if the first one doesn't work ): http://www16.brinkster.com/jonmack/adeskclock_temp.htm

It's still very early in progress, and like I said, I've never programmed in python, or imlib2. I only know a bit of Java and ActionScript :shock: I was having a few problems with it though, and thought some other people might want to have a nosey through it? Also, to make sure I'm doing it right :D

Problems so far -
- if I use a *.png image for clockface, how do I get it to scale with the window size? The window would change, but the image always remained at 100% size.
- gave up on images and switched to just (basic) vector stuff, and some weird things are happening when the hands get in the top half of the clock!
- the angle calculations could be cleaned up a lot, but I already have ideas for that


Anyway, I just thought it was cool to be able to create something so quickly. I'd welcome any feedback and ideas for future improvement, and also on my python code. What's everyone else working on?

Now I can get some sleep... :)

Regards,

By ZeroDivide (Desklet Author), on Thu Mar 10 00:23:18 2005.

hey jonmack,

I took a quick look at your code and the clock face problem should be an easy fix.

Code:

       adesklets.blend_image_onto_image(self.clockFace, 1,
                                         0, 0, self.w, self.h,
                                         0, 0, self.w, self.h);



You are using the window width and height as your source_width and source_height instead of the clockFace width and height.

To get the width and height of your clockFace image do something like this

Code:


adesklets.context_set_image(self.clockFace)
width=adesklets.image_get_width()
height=adesklets.image_get_height()



and then you would scale it like this

Code:

adesklets.blend_image_onto_image(self.clockFace, 1,
                                         0, 0, width, height,
                                         0, 0, self.w, self.h);


I hope that helps you out a little.. Have fun making your clock :)

By syfou (Core Developer & Desklet Author), on Thu Mar 10 03:13:28 2005, last edited on Fri Mar 11 01:00:22 2005.

jonmack wrote:


and some weird things are happening when the hands get in the top half of the clock

Though luck... I think you just hit a bug within your imlib2 implementation of the infamous Bresenham algorithm. I just spent two hours verifying things... :headbash: I now know for sure:

This was very surprising to me, because what you did (drawing radius from a center point) is a canonical test case for Bresenham - but what we look at is clearly an artefact when drawing line segments with slopes in ]pi/4, 3*pi/4[ in rad. from i. So I do not know what to say - It's the first time in three months I experience such a problem with Imlib2, and [color=green:423fe672a9]src/lib/line.c from Imlib2 source tree is everything but trivial to fix.

So I suggest for now that you just "go around it", using tricks like image flipping, etc. Sorry for the burden. ...Or maybe simply reverting back on using images would be a good idea - I can assure your this part of things is working without a single hitch - It's far more commonly used.

I should be able to take some time during the weekend to look at your code more closely - I am a bit busy for the rest of the week. Thanks for sharing your efforts - have fun with your desklet!

By jonmack (User), on Thu Mar 10 08:40:39 2005: version 0.0.2.

Hi guys,

First, thanks for your inputs. I'm in a real rush to get to Uni, so I'll reply longer this evening :oops:, but v0.0.2 is ready :D ( same link as top post )

By jonmack (User), on Thu Mar 10 16:46:35 2005.

Time for a proper reply :)

ZeroDivide
Thanks a lot for explaining that, I think I understand how it works now. It's working perfectly - the clock face image now scales to fit the size of the window. Cheers.

syfou

Quote:

Though luck... I think you just hit a bug within your imlib2 implementation of the infamous Bresenham algorithm. I just spent two hours verifying things... :headbash:

Ouch :? Thankyou for taking the time to varify this for me, I appreciate it. Although it sounds like it would be better if it was something wrong with my code! ;) But context independent reproducibility, well... I can't really argue with that.

I've managed to revert back to using images for all the hands now, and they are working satisfactory so far. Just got a few pixel offset registering problem, but I'm working on it.


Anyway, thanks again. Anyone have any other ideas to add to it?

By syfou (Core Developer & Desklet Author), on Thu Mar 10 18:07:56 2005, last edited on Fri Mar 11 01:05:36 2005.

Hi Jon,

I looked at your code; mostly cool, but here is a few things I noticed that could be improved: As for the rest (Configuration, possible amelioration, etc), it's up to you, really. :-)

By ZeroDivide (Desklet Author), on Thu Mar 10 19:04:51 2005.

I'm glad to hear you got it working jonmack :D

jonmack wrote:

Anyway, thanks again. Anyone have any other ideas to add to it?


How about adding some numbers to the clock face? I can never tell what time it is without them. :?

By jonmack (User), on Fri Mar 11 06:40:34 2005.

Thanks for the repsonses,

Quote:

Your ADeskClock::get*Angle() methods are not very efficient:

Yeah, that's one thing I've been working on. I have already spotted the multiple time.time() things, and now just refresh one currentTime variable to be used everywhere. I don't quite know enough phython to understand how your condensed code example fully works, but it's all part of the learning process I guess. I will study it.

I did condense them all down into one getAngle(handType) method in v0.0.3, but then in 0.0.4 reintroduced separate get*Angle() methods, since the hour hand now work differently - it steps in quarter hour angles for more accuracy, whilst minute and second only ever point to integer minutes/seconds.

Quote:

You redraw the whole window image onto buffer at each step

This is another thing that I'm aware of, but just not confident enough yet to try and seperate it. It's on my to-do list now though ;)

Quote:

In this case, there is no need to call ADeskClock::render() from ADeskClock::ready(), since ADeskclock::alarm() is called right after ADeskClock::render() returns anyway.

Hmm, me thinks I need to study the adesklets API a little bit more. Thanks for the tips.

Quote:

How about adding some numbers to the clock face?

Hehheh :D I know, I've put some "big dots and small dots" (tm) in v0.0.4 to help with that. I'm not really good with digital art, so the graphics could be much better.

---

The whole thing will most probably need a re-write at some stage, as I learn more about python and to clean it up/make it efficient. I'll put the latest two versions up now anyway. v0.0.3 just has a single getAngle() method, but I've had to put them back in v0.0.4, since I didn't know how else to have different calculations done for each hand.

Thanks once again guys, I really mean it. Your support has been great!

Regards,

By CitizenX (Themer / Graphic Artist), on Mon Mar 14 05:39:22 2005.

How about some skins? The default clock is pretty enough, but didnt quite go with my Flux theme....so I made a new skin. Just changed the filenames in adeskclock.py to point to the new skinfiles...but thats a thought for the config file.

By jonmack (User), on Mon Mar 14 13:13:04 2005.

Hi CitizenX,

Thanks for the input.

Well I'm not bad with the old fashioned paper and pencil, but when it comes to digital art, I'll be the first to admit that I suck ;) Hopefully one day some kind gifted artist will lend some better skins - or I suppose I could go hunting for some "open source" ones maybe.

When I get round to a config file you will of course be able to change the graphics. The hands are what might be a little tricky in the future - they don't automatically scale at the moment - but it's on the to-do list :)

By syfou (Core Developer & Desklet Author), on Mon Mar 14 13:28:09 2005.

CitizenX wrote:


.so I made a new skin. Just changed the filenames in adeskclock.py to point to the new skinfiles

Do you have a public link somewhere to it?

jonmack wrote:


When I get round to a config file you will of course be able to change the graphics. The hands are what might be a little tricky in the future - they don't automatically scale at the moment - but it's on the to-do list

What about a first submission for official inclusion on adesklets site? Would you put it on your to-do list? :prayer:

By jonmack (User), on Mon Mar 14 15:37:28 2005.

syfou wrote:


What about a first submission for official inclusion on adesklets site? Would you put it on your to-do list? :prayer:


:D It's on!! I will see about getting things together for an official entry later tonight ( hopefully ). I've been reading the requirements link you sent me.

By CitizenX (Themer / Graphic Artist), on Mon Mar 14 18:44:29 2005.

Heres a screenshot with my Gold clock skin...I've got it in silver and ClearSilver...no center face and the hands are small arrows. If theres a need for more skins send ideas my way...this took me maybe 30 min. I'll come up with some more if you're interested.

By syfou (Core Developer & Desklet Author), on Mon Mar 14 18:50:38 2005.

CitizenX wrote:

Heres a screenshot with my Gold clock skin...I've got it in silver and ClearSilver...


I must say it is very good looking. :-) It is entirely your artwork? That's nice! Thanks for the screenshot submition on lynucs.org by the way.

By CitizenX (Themer / Graphic Artist), on Mon Mar 14 19:36:36 2005.

Thanks for the compliment. :) The clock is original, the desktop sadly...is not mine (but I'll post some of my own work now). Here are my Silver and ClearSilver skins...built off of the Gold skin but with different colors and a bit different design. The first skin took about 30 min to do, the others were nothing after that. I'll work on some more ideas if we're interested.

By jonmack (User), on Mon Mar 14 20:35:53 2005.

Wow! :shock: Very nice skins CitizenX, I like them. Especially the see-through one, ClearSilver. If you want to share your work, I'd be thrilled to have them included with my adesklet. Would be nice for poeple to have a small collection to choose from straight away.

How are you finding skinning the hands? I guess it was not quite so obvious which way they should go from my symmetric ones :) They still pivot around the top-left corner, I'll be working on making it so they can pivot around any point ( so we can have hands that extend a short way in the opposite direction, if you get what I mean ).

P.S. Syfou... I'm trying hard to submit v0.0.5 ;) But I have no mail servers on my box, I'm just stuck with web-based mail right now, hotmail and gmail. I have absolutely no idea if they'll play nice. Hopefully it'll work when I send it now, but if not, I'll try again later tomorrow maybe.

By syfou (Core Developer & Desklet Author), on Mon Mar 14 21:08:24 2005, last edited on Tue Mar 15 01:23:19 2005.

jonmack wrote:


But I have no mail servers on my box, I'm just stuck with web-based mail right now, hotmail and gmail. I have absolutely no idea if they'll play nice.

You do not have one single valid smtp server you can talk to? :shock: Your school's from a unix account, your isp's, or alike? It doesn't need to be local: you just have to set the smtp_host variable from $HOME/.adesklets_submit file to fit your settings.

By CitizenX (Themer / Graphic Artist), on Tue Mar 15 01:12:59 2005.

Thanks jon. I'd be happy to share my skins with ya...I'm thinking of a few alternative designs (just to see what kind of trouble I can get myself into), so I'll send them along whenver you like.

The hands weren't a problem...yeah I had them backwards when I did Gold...but once I figured it out it was fine.

I've had to take a couple of shortcuts because they pivot from that corner, but it wasn't that big of a problem. I'd like to be able to pivot from any point, then I can model that central pin well...heck I can do it in the clockface, and give the first few pixels of the hands transparency...hmm.....

You know, gmail isn't just web-based...I use the smtp server all the time. Once I feel alright with upgrading python, mailer will take the place of my torsmo script (dont like the cron job I have set up for it...too many resources to run.).

By jonmack (User), on Mon Mar 21 21:27:10 2005.

I'm still alive ;) Been very busy this week...

I've since recieved CitizenX's skins, and also some from a ( russian, I think ) chap called Igor. I'm reworking the skin system for the next version, so all these new skins ( and other ones in the future ) can easily be switched. The precise pivoting is underway too, yay \o/

Syfou, I really don't know how these things work underneath ( M$ zombie for 10 years :roll: ), so I'm having information overload after switching to linux. I've tried to study these things in my spare time. I thought I need to have some sort of MTA to send it to a SMTP server? I think I can use my ISP's SMTP. ( I knew there was something I forgot to ask in that email I just sent you CitizenX... how do you use gmail's SMTP?! :D ).

Anyway, I'm away for the next fortnight, so I won't be able to be around much. I'll get the next version nice and sorted ( a lot of it re-written ), and that will be a much better candidate for submission. And it will have all these lovely skins :)

Regards,

By syfou (Core Developer & Desklet Author), on Mon Mar 21 23:15:33 2005, last edited on Tue Mar 22 12:45:14 2005.

jonmack wrote:


Syfou, I really don't know how these things work underneath ( M$ zombie for 10 years Rolling Eyes ), so I'm having information overload after switching to linux. I've tried to study these things in my spare time. I thought I need to have some sort of MTA to send it to a SMTP server?


Using Python built-in mail transfert agent (MTA) or a third-party one is your choice, since both cases can be handled by adesklets_submit.

In adesklets documentation, I wrote:


For example, Belial Leviathan would fisrt check his beast desklet's entry by doing something similar to:

Code:


adesklets_submit beast


If everything goes fine, it will output the resulting submission email on stdout. From there, Belial can either:

  • Pipe it to his favorite MTA (mail transfert agent) to send it to adesklets@mailworks.org.
  • Make adesklets_submit send it itself by SMTP, using the smtp_host and smtp_port parameters in its $HOME/.adesklets_submit. For this, Belial would use:

Code:


adesklets_submit --send beast




[EDIT]

I just signed up to gmail myself, so I can give you the information:
As you see, this smtp server is not anonymous, as it requires authentification. Since I didn't include this facility in adesklets_submit, you need to use an external program to send it to gmail's smtp server. It can very well be any properly configured email client, but just make sure it doesn't alter the message (potential attachments, line breaks, etc.). Alternatively, you can very well install locally a simple relay-only MTA supporting smtp over ssl with autentification (such as esmtp) and use it.

Regards,

By deniz_vs (User), on Tue Mar 22 01:09:17 2005.

CitizenX wrote:

Thanks jon. I'd be happy to share my skins with ya...I'm thinking of a few alternative designs (just to see what kind of trouble I can get myself into), so I'll send them along whenver you like.

Hello

Yes. I'm from Russia. At me it is some offers skins,

It would be not bad to enter parameters of imposing - for example all over again a second hand then a background then hour. And as definition of a point of turn in what or a file describing skin.
Jonny think of it plz

Regards,
Igor Pisorev, Russia, St. Peterburg
PS
and small announcement


http://deniz.chat.ru/screenshot.png
I think how to appear by then Jonny I shall have time to make five skins, the main thing of idea is

By jonmack (User), on Sat May 28 11:40:24 2005: Heeeere's Jonny!.

Hi everyone!

Sorry I've been gone so long. 2 weeks... 2 months. Same difference ;)

So anyway, my last year of University is over now, so I have time again to pick up my hobby projects. I've started work on adeskclock again. So far I have clock-hand pivot points working quite well, so it looks much nicer. I'm in the process of adding config files per skin, and the skinable/switching code is almost done. Also trying to fix the next version of my website with a proper page for this thing, so no more temp page. Expect more news and hopefully an actual release ( :roll: ) very Soon(TM)!

By cs-cam (Desklet Author), on Fri Jun 10 01:48:56 2005.

deniz_vs: Mmmm, very nice skin :D I'dprobably use the clock with that skin, I just need to get a few local issues sorted out.


adesklets is proud to be hosted on:

SourceForge.net Logo

Back to adesklets.sf.net.