Skip to content

Instantly share code, notes, and snippets.

@Myoga1012 Myoga1012/Calendar.ini
Last active Aug 29, 2015

Embed
What would you like to do?
Rainmeterのスキンでカレンダーを表示してみました。スクリプト用の言語はLuaです。
[Rainmeter]
Author = Myoga Screw-bright (旧名:Myoga S. Tomonaka)
; Twitter : https://twitter.com/Myoga1012
Update = 1000
[Metadata]
Name = Calendar
Description = 現在の月のカレンダーを表示します。
License = Creative Commons BY-NC-SA 3.0
Version = 1.00
[Variables]
; 背景色
Season0 = 228B22FF ; 春(若草)
Season1 = 0000FFFF ; 夏(海)
Season2 = BA3725FF ; 秋(紅葉)
Season3 = C0C0F0FF ; 冬(雪)
; フォント設定
[FontDate]
FontSize = 22
StringStyle = Bold
StringAlign = Right
FontFace = HGS行書体
FontColor = FFFFFFFF
StringEffect = Border
FontEffectColor = 000000FF
AntiAlias = 1
[FontDateSun]
FontSize = 22
StringStyle = Bold
StringAlign = Right
FontFace = HGS行書体
FontColor = FF80CCFF
StringEffect = Border
FontEffectColor = 000000FF
AntiAlias = 1
[FontDateSat]
FontSize = 22
StringStyle = Bold
StringAlign = Right
FontFace = HGS行書体
FontColor = 80CCFFFF
StringEffect = Border
FontEffectColor = 000000FF
AntiAlias = 1
; プラグインの読み込み
[MeasureDateY] ;
Measure = Time
Format = "%Y"
[MeasureDateM] ;
Measure = Time
Format = "%m"
[MeasureDateMN] ; 月名
Measure = Time
Format = "%m"
Substitute = "10" : "神無月", "11" : "霜月", "12" : "師走", "01" : "睦月", "02" : "如月", "03" : "弥生", "04" : "卯月", "05" : "皐月", "06" : "水無月", "07" : "文月", "08" : "葉月", "09" : "長月"
[MeasureDateDay] ;
Measure = Time
Format = "%d"
[MeasureDateDate] ; 曜日
Measure = Time
Format = "%w"
; スクリプトの呼び出し
[CalLua]
Measure = Script
ScriptFile = Calendar.lua
; 描画部
; バックグラウンド
[MeterBackGround]
Meter = IMAGE
X = 0
Y = 0
W = 310
H = 340
; キャラ
[MeterChara]
Meter = IMAGE
X = 10
Y = 120
W = 290
H = 180
ImageName = "all.png"
; 年月表示
[MeterLabel]
MeasureName = MeasuredateY
MeasureName2 = MeasuredateMN
Meter = STRING
MeterStyle = FontDate
StringAlign = Center
X = 150
Y = 10
Text = "%1年 %2"
; 曜日表示
[MeterSunday]
Meter = STRING
MeterStyle = FontDateSun
X = 50
Y = 50
Text = ""
[MeterMonday]
Meter = STRING
MeterStyle = FontDate
X = 40r
Y = 0r
Text = ""
[MeterTuesday]
Meter = STRING
MeterStyle = FontDate
X = 40r
Y = 0r
Text = ""
[MeterWednesday]
Meter = STRING
MeterStyle = FontDate
X = 40r
Y = 0r
Text = ""
[MeterThursday]
Meter = STRING
MeterStyle = FontDate
X = 40r
Y = 0r
Text = ""
[MeterFriday]
Meter = STRING
MeterStyle = FontDate
X = 40r
Y = 0r
Text = ""
[MeterSaturday]
Meter = STRING
MeterStyle = FontDateSat
X = 40r
Y = 0r
Text = ""
; 日付表示
; Week 1
[MeterW1D1]
Meter = STRING
[MeterW1D2]
Meter = STRING
[MeterW1D3]
Meter = STRING
[MeterW1D4]
Meter = STRING
[MeterW1D5]
Meter = STRING
[MeterW1D6]
Meter = STRING
[MeterW1D7]
Meter = STRING
; Week 2
[MeterW2D1]
Meter = STRING
[MeterW2D2]
Meter = STRING
[MeterW2D3]
Meter = STRING
[MeterW2D4]
Meter = STRING
[MeterW2D5]
Meter = STRING
[MeterW2D6]
Meter = STRING
[MeterW2D7]
Meter = STRING
; Week 3
[MeterW3D1]
Meter = STRING
[MeterW3D2]
Meter = STRING
[MeterW3D3]
Meter = STRING
[MeterW3D4]
Meter = STRING
[MeterW3D5]
Meter = STRING
[MeterW3D6]
Meter = STRING
[MeterW3D7]
Meter = STRING
; Week 4
[MeterW4D1]
Meter = STRING
[MeterW4D2]
Meter = STRING
[MeterW4D3]
Meter = STRING
[MeterW4D4]
Meter = STRING
[MeterW4D5]
Meter = STRING
[MeterW4D6]
Meter = STRING
[MeterW4D7]
Meter = STRING
; Week 5
[MeterW5D1]
Meter = STRING
[MeterW5D2]
Meter = STRING
[MeterW5D3]
Meter = STRING
[MeterW5D4]
Meter = STRING
[MeterW5D5]
Meter = STRING
[MeterW5D6]
Meter = STRING
[MeterW5D7]
Meter = STRING
; Week 6
[MeterW6D1]
Meter = STRING
[MeterW6D2]
Meter = STRING
[MeterW6D3]
Meter = STRING
[MeterW6D4]
Meter = STRING
[MeterW6D5]
Meter = STRING
[MeterW6D6]
Meter = STRING
[MeterW6D7]
Meter = STRING
-- 名前 : Myoga Screw-bright (旧名:Myoga S. Tomonaka)
-- Twitter : https://twitter.com/Myoga1012
-- 初期化処理です。
function Initialize()
-- カレンダーの文字スタイルを設定します。
for cur = 0, 41 do
-- 日曜は赤系、土曜は青系、平日は白系です。
if cur % 7 == 0 then
SKIN:Bang( '!SetOption', Days.Name:format( cur / 7 + 1, 1 ), 'MeterStyle', 'FontDateSun' )
elseif cur % 7 == 6 then
SKIN:Bang( '!SetOption', Days.Name:format( cur / 7 + 1, 7 ), 'MeterStyle', 'FontDateSat' )
else
SKIN:Bang( '!SetOption', Days.Name:format( cur / 7 + 1, cur % 7 + 1 ), 'MeterStyle', 'FontDate' )
end
-- 日付のXY座標を設定します。
SKIN:Bang( '!SetOption', Days.Name:format( cur / 7 + 1, cur % 7 + 1 ), 'X', 40 * ( cur % 7 ) + 50 )
SKIN:Bang( '!SetOption', Days.Name:format( cur / 7 + 1, cur % 7 + 1 ), 'Y', 40 * ( math.floor( cur / 7 ) ) + 90 )
end
end
Season = { Name = 'Season%d' }
Days = { Name = 'MeterW%dD%d' }
-- 周回処理です。スキン設定ファイルの[Rainmeter].Updateの時間ごとに呼び出されます。
function Update()
-- 季節に合わせて背景色を変えます。
SKIN:Bang( '!SetOption', 'MeterBackGround', 'SolidColor',
SKIN:GetVariable( Season.Name:format( math.floor( ( SKIN:GetMeasure( 'MeasureDateM' ):GetValue() + 9 ) % 12 / 3 ) ), '00000000' ) )
for cur = 0 , 41 do
SKIN:Bang( '!SetOption', Days.Name:format( cur / 7 + 1, cur % 7 + 1 ), 'Text', '' )
end
-- スキン設定ファイルから年月日曜日を取得し、1日の曜日と月末日を求めます。
year = SKIN:GetMeasure( 'MeasureDateY' ):GetValue()
mon = SKIN:GetMeasure( 'MeasureDateM' ):GetValue()
day = SKIN:GetMeasure( 'MeasureDateDay' ):GetValue()
date = SKIN:GetMeasure( 'MeasureDateDate' ):GetValue()
prePad = ( 7 - ( day % 7 + 6 - date ) % 7 ) % 7
if mon == 2 then
if year % 4 == 0 then lastDay = 29 else lastDay = 28 end
else
if mon <= 7 and mon % 2 ~= 0 or mon >= 8 and mon % 2 == 0 then lastDay = 31 else lastDay = 30 end
end
-- カレンダーを出力します。
for curDay = 1, lastDay do
cur = curDay + prePad - 1
SKIN:Bang( '!SetOption', Days.Name:format( cur / 7 + 1, cur % 7 + 1 ), 'Text', curDay )
end
return 0
end
-- Calender.lua( Rainmeterのスキン用 )
-- Copyright (c) 2014 Myoga-TN.net All Rights Reserved.
-- This script is released under the Creative Commons BY-NC-SA 3.0 License.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.