It is currently April 24th, 2024, 12:54 pm

Hello from Montreal

Introduce yourself to the Rainmeter community!
kysko
Posts: 4
Joined: June 21st, 2019, 3:07 am

Hello from Montreal

Post by kysko »

Although I've know about Rainmeter for many years, never found an incentive to use it, the "gadgets" on Win7 where enough... until I "converted" to Win10 a year ago or so, when I found I missed some things...

So, of course, I compiled Rainmeter (like anyone would do, right? O.O ), inspected a few skins, and still trying my hand at making (awkwardly for now) a few ones.

One of my first idea was to make a sunrise/sunset skin with Lua... until I found that the path had been beaten at least since 2012! :thumbup:
Tremendous skins out there! :bow: The Calender.lua code in particular, beyond my knowledge of Lua for now (darn metatables!).

Anywhoo, that's it for now...
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hello from Montreal

Post by balala »

kysko wrote: June 21st, 2019, 3:22 am Although I've know about Rainmeter for many years, never found an incentive to use it, the "gadgets" on Win7 where enough... until I "converted" to Win10 a year ago or so, when I found I missed some things...

So, of course, I compiled Rainmeter (like anyone would do, right? O.O ), inspected a few skins, and still trying my hand at making (awkwardly for now) a few ones.
Welcome aboard, kysko.
Yes, Rainmeter is great software, with a lot of already written great skins. And new ones are coming out every day.
kysko wrote: June 21st, 2019, 3:22 am One of my first idea was to make a sunrise/sunset skin with Lua... until I found that the path had been beaten at least since 2012! :thumbup:
Tremendous skins out there! :bow: The Calender.lua code in particular, beyond my knowledge of Lua for now (darn metatables!).
Yep, there are more such skins. Most of them are parsing the information from Internet, but there are some which make the calculations, without accessing Internet. Just to promot one of my previous works: https://forum.rainmeter.net/viewtopic.php?f=27&t=24740&p=130792&hilit=sunmoon#p130759
kysko
Posts: 4
Joined: June 21st, 2019, 3:07 am

Re: Hello from Montreal

Post by kysko »

yes, I've been reviewing many algorithms for equation of time, declination, sunrise, sunset, etc, didn't want to fetch data.
I've already implemented a simple one in pure rainmeter code, accurate enough for daily needs.

I had seen your code; I thought I saw an implementation error for getting the julian days since jd2000, but I might be mistaken.
You see, when I use a lua 5.1.5 command line, print(1/3) gives me 0.3333... and print(4/3) gives 1.3333..., so I thought lua didn't have integer division.
Usually the algorithm you (seem to) use is for integer division, so with math.floor in lua.

In fact, a quick check shows that not using the floor function doesn't give a big error after all!

To be sure, such a function should give 0 for (y,m,d,h)=(2000,1,1,12); yours gives -0.9, while using math.floor it gives 0 as expected.
For (y,m,d,h)=(2019,6,21,12), your function gives 7110.896..., while using math.floor we get 7111.0, which is quite close!
I had never thought to compare the error given by not using integer division... now I see it!

But then again... (2019.5 - 2000)*365.24 - 10 days left in june = 7112.18, which isn't bad either if you don't care about astronomic-wise precision!

Anyway, I learn a lot by inspecting skins such as yours and many others, thanks.
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hello from Montreal

Post by balala »

In fact there are two different lua function for integer division: math.floor and math.ceil. They are returning
the integer no greater than or no less than the given value (even for negatives).
(Source)
A simple Round function also can be implemented.
kysko
Posts: 4
Joined: June 21st, 2019, 3:07 am

Re: Hello from Montreal

Post by kysko »

yes, and for the usual truncation in those Julian converters, math.floor is the one when the argument is positive (math.ceil if negative); in the case of your algo, math.floor will do (and also taking care of precedence, eg. 7*4/5 would be floor( (7*4) / 5 ), and not 7* floor(4/5) ).

rounding is a different animal, which has different behavior above/below 0.5
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hello from Montreal

Post by balala »

kysko wrote: June 22nd, 2019, 7:35 pm rounding is a different animal, which has different behavior above/below 0.5
Yep, I recommended using one (any) implementation of the Round function.