Jump to content
Korean Random
ktulho

Аналоговые часы.

Recommended Posts

Решил для разнообразия сделать аналоговые часы.

 

clock.gif.b317b9d7b0153840c544343efa29956d.gif

 

Подключение:

1) В файл widgets.xc добавить:

${ "widgetsTemplates.xc":"analogWatch" }

2) в widgetsTemplates.xc добавить:

  "analogWatch": {
    "enabled": true,
    "layer": "normal",
    "type": "extrafield",
    "formats": [
      {
        "width": 152,
        "height": 152,
        "x": 450,
        "y": 150,
        "format": "<img src='xvm://res/AnalogWatch/CABg.png'>"
      },
      {
        "updateEvent": "ON_EVERY_SECOND",
        "rotation": "{{py:xvm.hourHand}}",
        "width": 77,
        "height": 77,
        "x": 527,
        "y": 227,
        "format": "<img src='xvm://res/AnalogWatch/CAH.png'>"
      },
      {
        "updateEvent": "ON_EVERY_SECOND",
        "rotation": "{{py:xvm.minuteHand}}",
        "width": 77,
        "height": 77,
        "x": 527,
        "y": 227,
        "format": "<img src='xvm://res/AnalogWatch/CAM.png'>"
      },
      {
        "updateEvent": "ON_EVERY_SECOND",
        "rotation": "{{py:xvm.secondHand}}",
        "width": 77,
        "height": 77,
        "x": 527,
        "y": 227,
        "format": "<img src='xvm://res/AnalogWatch/CAS.png'>"
      },
      {
        "width": 12,
        "height": 12,
        "x": 520,
        "y": 220,
        "format": "<img src='xvm://res/AnalogWatch/center.png'>"
      }

    ]
  }

3) распаковать архив AnalogWatch.zip в \res_mods\mods\shared_resources\xvm\res\

AnalogWatch.zip

4) Скопировать скрипт в analogWatch.py в \res_mods\configs\xvm\py_macro\

analogWatch.py

 

Edited by ktulho
  • Upvote 14

Share this post


Link to post

Short link
Share on other sites

Красота. А с учетом того, что можно и свои картинки заюзать - вообще чего хошь можно натворить)

Share this post


Link to post

Short link
Share on other sites
5 часов назад, ktulho сказал:

Поправил скрипт в шапке.

спс., всё завелось

 

Edited by Scharfhobel

Share this post


Link to post

Short link
Share on other sites
17 часов назад, Scharfhobel сказал:

, а как хвостик (противовес) у секундной стрелки добавить?

К сожалению, параметр "rotation" вращает вокруг левого верхнего угла картинки, поэтому никак.

Share this post


Link to post

Short link
Share on other sites

Хотя я тут подумал. Если для "хвостика" использовать еще одну картинку, то наверное получиться.

Edited by ktulho

Share this post


Link to post

Short link
Share on other sites

Спасибо Саш за классное дополнение, для себя сделал в нашем урфошном стиле:

 

  • Upvote 1

Share this post


Link to post

Short link
Share on other sites

добавить в analogWatch.py ?

@xvm.export('xvm.tailSecondHand', deterministic=False)
def xvm_formatDate():
    d = datetime.now()
    return degrees(d.second / 30.0 * pi) + 45	

и в widgetsTemplates.xc добавить: ?

      {
        "updateEvent": "ON_EVERY_SECOND",
        "rotation": "{{py:xvm.tailSecondHand}}",
        "width": 77,
        "height": 77,
        "x": 527,
        "y": 227,
        "format": "<img src='xvm://res/AnalogWatch/CAST.png'>"
      },

и картинку CAST с хвостиком нарисовать и добавить?

CAST.png

Edited by Scharfhobel

Share this post


Link to post

Short link
Share on other sites

@Scharfhobel можно просто:

{
        "updateEvent": "ON_EVERY_SECOND",
        "rotation": "{{py:sum({{py:xvm.secondHand}}, 180)}}",
        "width": 77,
        "height": 77,
        "x": 527,
        "y": 227,
        "format": "<img src='xvm://res/AnalogWatch/CAST.png'>"
      },
  • Upvote 2

Share this post


Link to post

Short link
Share on other sites
5 часов назад, ktulho сказал:

@Scharfhobel можно просто:


{
        "updateEvent": "ON_EVERY_SECOND",
        "rotation": "{{py:sum({{py:xvm.secondHand}}, 180)}}",
        "width": 77,
        "height": 77,
        "x": 527,
        "y": 227,
        "format": "<img src='xvm://res/AnalogWatch/CAST.png'>"
      },

Yes! :great:

 

 

shot_1840.jpg

Share this post


Link to post

Short link
Share on other sites
08.02.2020 в 23:42, ktulho сказал:

Решил для разнообразия сделать аналоговые часы.

Следующие часы из кривых, BW шными векторами или тупо на твинлайте будешь делать? )  Или уже... 

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...