Digital Clock improvements

BlitzMax Forums/BlitzMax Programming/Digital Clock improvements

Grisu(Posted April) [#1]
Hello everyone,

I've been working on a simple digital clock to work with my little radio app.

Code:


I'm drawing each block of the digits individually, which is highly inefficent. But I want to add some visual effects to each block, if possible.

Is there a way to create a transparent image of the numbers "on the fly" [HH MM] and copy it onto the background each minute (excluding the middle dots)? This would reduce the CPU overhead and draw calls.

I'd also love to add some color changing to each indivdual digit rectangle for instance, but I'm unsure on how to do this effectively and visually pleasing. Perhaps there are some retro demo coders here assist. ;)

All in all I'd like to make the clock display a bit more interesting for the modern user. - Keep in mind, that the background will show different radio station logos. So the clock numbers have to be readable in different situations.

Any help or ideas are welcome. Thanks!
Grisu


degac(Posted April) [#2]
Hi, try using a PANEL and SetGadgetPixmap.

With a very tiny pixmap (ie: 20x8 pixels) then you can automatically stretch it to the pixmap on a panel.

edit:

simple experiment, no bound check on pixmap etc, so need to check it before 'drawing'




Grisu(Posted April) [#3]
Can't use a panel, need this to be a gfx canvas as it's used for much other stuff.


degac(Posted April) [#4]
OK, in this case I think there's no way: you should use your code and write it on the canvas.
Scaling a pixmap 'manually' is not so efficient, better draw directly on the image/original pixmap.

An option could be to use 'block image' instead of DrawBox: this will allow you to have nice gfx effect/change shape and color.
Drawing 15 'blocks' for a single digit maybe could be faster than calling 15 times DrawRect... but I never tested it.

edit:
using a Canvas and DrawRect... it should be easy to replace it with DrawImage



Grisu(Posted April) [#5]
Thanks Christian.

Will dig deeper into it over the week. Your code looks much more compact than mine. ;)

I'm forced to stay within certain code limits.

P.S.: Do you think a HH MM SS format is better than mine (HH : MM)?


Grisu(Posted April) [#6]
Uploaded an exe of PRP with the clock code implemented:
| link removed |



P.S.: You need a full version of PRP on your system and just copy the exe over. Select "Digital Clock" from the spectrum dropdown.

Too simplistic? Works fine though. :)


degac(Posted April) [#7]
Well I chose HH:MM:SS just to see the result as soon as possible: waiting a minute just to check the change was too much for my taste :D !
Of course it could be an option for your app...

My code is 'compact' just because I re-coded each single number in a 'pattern': of course you could use the same way to code even letters or symbols (like ':') to have a 'scrolling title' ... (another option of course).

I would like to test with images (just an idea: it's Christmas or Halloween? Just change the color/shape of any single image-block...)


Grisu(Posted April) [#8]
Switched back to images, think this looks better and gives better performance for sure.

Alpha 2:


For the season idea: I might hire an artist to do some new images (272x85 pixels each). So I can replace the default logo file for PRP below according to special events.



degac(Posted April) [#9]
'liquid crystal' style are very good!


Grisu(Posted April) [#10]
Thanks for the feedback!



I uploaded a temp exe build here for the current version:
http://www.mediafire.com/file/2283lrr3lhbvvxp/prp_test.zip