図形描画(リージョン)

お勧めスクリーンセーバーで紹介しているAnalog DIN Clock をリージョンを使って丸いウィンドウにする方法を紹介します。

スクリーンセーバープラグインを使って Analog DIN Clockを表示しておきます。 Analog DIN Clockの設定で、サイズを最大、移動をなしにします。

DIN Clock設定

ポップアップメニューから付箋のファイル名を確認しておきます。 (下記の例では20161005234730の部分です。) Luaスクリプトの付箋を作成し、以下のスクリプトを入力します。

x = 'DIN Clockのリージョン設定'
require('FusenUtils')
require('color')
f_SetInterval(1000)
function DrawRegion()
  path = gdi:Path()
  if cw < ch then
    r = gdi:Rectangle(1, (ch-cw)/2, cw-3, cw)
  else
    r = gdi:Rectangle((cw-ch)/2, 1, ch, ch-3)
  end
  path:AddEllipse(r)
  r2 = gdi:Rectangle(cw - 20, ch - 20, 20, 20)
  r3 = gdi:Rectangle(cw - 20, ch - 20, 16, 16)
  path:AddRectangle(r2)
  path:AddRectangle(r3)
  rgn = gdi:Region(path)
  DINClock.Region = rgn
end
DINClock = FindFusen('20161005234730')
cw,ch = DINClock.Width, DINClock.Height
sw,sh = sw or 100, sh or 100
if (sw ~= cw) or (sh ~= ch) then
  DrawRegion()
  sw,sh = cw,ch
end
 
comments powered by Disqus