Recent

Author Topic: CATWW  (Read 3157 times)

Handoko

  • Hero Member
  • *****
  • Posts: 3752
  • My goal: build my own game engine using Lazarus
CATWW
« on: August 11, 2020, 07:52:25 pm »
Clocks Around The World-Wiser
-----------------------------

A world-clock for the community made by the community
Version 0.1
Now version 0.2


From the previous discussions, we got an idea to build a world clock.
Here is the demo, all suggestions are welcome.

  • It is only version 0.2, a lot of features already planned but not implemented yet.
  • The program should be looking good, cross platform and able to run on old hardware.
  • I choose BGRABitmap as the graphics engine, may use others if it is not fast enough.
Todo list (Handoko's tasks):
  • Improve the performance (done in v0.2)
  • Consider to use OpenGL
  • It will looks nicer if each clock is smaller a bit (done in v0.2)
  • User-choose-able skins
  • Able to save user preferences
  • A button (maybe a small red button) to show the credit page
  • A button at the lower right of each clock to set the time
  • Somewhere to show UTC time, perhaps on the title bar
Requirement:

To able to compile it, BGRABitmap need to be installed. Here is how to install BGRABitmap:
Lazarus main menu > Package > Online Package Manager > BGRABitmap > Install > From repository
« Last Edit: August 18, 2020, 07:05:25 pm by Handoko »

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: CATWW
« Reply #1 on: August 11, 2020, 11:00:23 pm »
I like it.
I kind of like the square clock. The header has some possibilities.

« Last Edit: August 12, 2020, 03:30:17 am by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

MaxCuriosus

  • Full Member
  • ***
  • Posts: 111
Re: CATWW
« Reply #2 on: August 12, 2020, 12:52:31 am »
My suggestions:

1. Round clock only.
2. Short and thick tail ("counter-weight") to each hand
3. Add a digital elapsed time that starts when the program starts.
« Last Edit: August 12, 2020, 01:36:41 am by MaxCuriosus »

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: CATWW
« Reply #3 on: August 12, 2020, 03:06:54 am »
Indeed it runs slow, all the clocks are not sinced I say when they move the hands.

And it behaves strange on Windows, I cant move the window not close it, I must kill the app.

Handoko

  • Hero Member
  • *****
  • Posts: 3752
  • My goal: build my own game engine using Lazarus
Re: CATWW
« Reply #4 on: August 12, 2020, 04:36:09 am »
3. Add a digital elapsed time that starts when the program starts.

Thank you for your suggestions, but I do not fully understand. Can you explain more about it?

eny

  • Hero Member
  • *****
  • Posts: 1608
Re: CATWW
« Reply #5 on: August 12, 2020, 12:36:05 pm »
On Windows the main form, that is hidden, is still the 'focused' one.
So the clock form cannot be changed (mininimized/maximized etc.).
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Handoko

  • Hero Member
  • *****
  • Posts: 3752
  • My goal: build my own game engine using Lazarus
Re: CATWW
« Reply #6 on: August 12, 2020, 12:55:12 pm »
Thank you for informing this issue. I use Linux, I have no such problem.

I'm not sure but I found I accidentally disabled the Clock form., maybe this is the culprit that cause the problem. I'll inspect it later.

MaxCuriosus

  • Full Member
  • ***
  • Posts: 111
Re: CATWW
« Reply #7 on: August 12, 2020, 01:00:17 pm »
3. Add a digital elapsed time that starts when the program starts.

Thank you for your suggestions, but I do not fully understand. Can you explain more about it?

Handoko,
visualize  your clock with a transparent background and a separated but "docked" rectangle below that displays the elapsed time in digital form.

Handoko

  • Hero Member
  • *****
  • Posts: 3752
  • My goal: build my own game engine using Lazarus
Re: CATWW
« Reply #8 on: August 12, 2020, 01:21:58 pm »
What would the elapsed time used for?
My phone has elapsed timer, I used it as an alarm when I am boiling water.

eny

  • Hero Member
  • *****
  • Posts: 1608
Re: CATWW
« Reply #9 on: August 12, 2020, 01:52:59 pm »
Did a quick test on windows with laz x64 with a 4x4 grid.
Watching time passing like thas has a medidative effect  :D

  • I would put all clock (drawing) functionality in a class of it's own, to separate it from any display canvas (form, frame, image etc.).
  • Updating goes very slow. In a 4x4 grid it takes a full second to update all clocks. I assume it has to do with all the BGRA rotations.
    You could buffer the images (with the background and the 2 main hands) and update them once a minute. And then only overlay the second hand each second. This only works ofc for railway station type clocks that don't smoothly update the hour and minute hands.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Handoko

  • Hero Member
  • *****
  • Posts: 3752
  • My goal: build my own game engine using Lazarus
Re: CATWW
« Reply #10 on: August 12, 2020, 02:13:56 pm »
Thank you for the suggestions.

I thought about using class. But I choose the old-school way (not using class) so more newbies can study the code easier.

Previously I used panels. But I decided not to use it because think drawing it directly on a single canvas will have better performance.

I am doing the optimization now, I managed to make it run a bit faster. Yes, I saw some flicker issue and already used buffer.
« Last Edit: August 18, 2020, 07:11:19 pm by Handoko »

TRon

  • Hero Member
  • *****
  • Posts: 536
Re: CATWW
« Reply #11 on: August 12, 2020, 04:34:12 pm »
@Handoko:

Nice looking !

You already am aware of the underpowered hw I test on, but wanted to let you know as an indication that in case I activate all clocks and making the form about a quarter size of my screen (1920x1080) that it takes about 4-5 seconds for the seconds-hands to 'update'.

MathMan

  • Full Member
  • ***
  • Posts: 205
Re: CATWW
« Reply #12 on: August 12, 2020, 04:49:12 pm »
Thank you for the suggestions.

I thought about using class. But I choose the old-school way (not using class) so more newbies can learn from it.

Previously I used panels. But I decided not to use it because think drawing it directly on a single canvas will have better performance.

I am doing the optimization now, I managed to make it run a bit faster. Yes, I saw some flicker issue and already used buffer.

First I have to admit I do not know anything about BGRABitMaps. But looking through 'Clocks.pas' I do see that you are doing three affine transformations (rotation plus elongation I assume) every timer tick. Affine transforms are expensive operations usually. So this can be improved massively, if you are willing to spend more memory. Just pre calculate the 60 affine transforms required for every hand (seconds, minutes & hours) and then simply map them on the clock background at the timer tick. You would of course need to re-calculate these in case of a canvas re-size then.

Cheers,
MathMan

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: CATWW
« Reply #13 on: August 12, 2020, 05:26:55 pm »
You don't need to calculate the 60 transformations if you want to cache them. For example you can calculate a quarter, say the first 15, then flip horizontally and vertically as needed, that's much faster.

MathMan

  • Full Member
  • ***
  • Posts: 205
Re: CATWW
« Reply #14 on: August 12, 2020, 05:36:53 pm »
You don't need to calculate the 60 transformations if you want to cache them. For example you can calculate a quarter, say the first 15, then flip horizontally and vertically as needed, that's much faster.

Yeah, good point. Would make the update on the timer tick a bit more complex, but would reduce the memory footprint by 4. Sounds like a good compromise.

 

TinyPortal © 2005-2018