It is currently May 7th, 2024, 7:55 pm

[Solved] Calendar Date Position Drift

Get help with creating, editing & fixing problems with skins
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

[Solved] Calendar Date Position Drift

Post by Kaelri »

I've got one for you guys.

This issue arose after I modified limpet's Calendar skin to use an adjustable variable for the width of the skin. The X position of each meter is based on two variables: #FirstX#, which is used by the first date in the row, and #SpacingX#, which is used by each subsequent date (as in X=#SpacingX#r).

Code: Select all

FirstX=38
SpacingX=((#SidebarWidth#-#FirstX#-19)/6)
I also have a pair of meters which indicate the current date. One is is a STRING meter with formatting identical to the regular dates, except that it's bold. The other is a small solid-color IMAGE meter. The X position of both of these meters is a dynamic measure, based on the day of the week (0 = Sunday, 1 = Monday, etc).

Code: Select all

[msWeekDay2]
Measure=CALC
Formula=#FirstX#+msWeekDay*#SpacingX#
The problem is this: as the week goes on, the value of [msWeekDay2] shows an increasing drift to the right (i.e. a higher X) relative to the regular date meters.

Image
Image
Image
Image

I believe this is some sort of rounding error. If I calculate SpacingX by hand - in this case, with a total #SidebarWidth# of 500, the value of SpacingX comes to 73.83333 - the same error occurs. If I manually round it off to 74, it displays correctly. However, if I change [msWeekDay2] to use ROUND(#SpacingX#), the drift is only exaggerated.

Any idea why this is happening? I know I can probably fix it by changing how the regular meters get their X, but I'd like to solve it on this end, if possible.
EnigmaCalendarDebug.rmskin
You do not have the required permissions to view the files attached to this post.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Calendar Date Position Drift

Post by smurfier »

I don't know if this is related to your problem, but I suggest switching to:

Code: Select all

[msWeekDay2]
Measure=Calc
Formula=#FirstX#+msWeekDay*#SpacingX#
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Calendar Date Position Drift

Post by Kaelri »

Doesn't change anything, but that does simplify things. Thanks. (Post updated.)
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Calendar Date Position Drift

Post by smurfier »

I made another small change, and fixed the problem.

Code: Select all

;-----------------------
; INDICATOR

;Made this smaller using a simple formula
[msWeek]
Measure=CALC
Formula=#FirstY#+(CEIL((mDay+cMonthStart-1)/7)-1)*#SpacingY#

[msWeekDay]
Measure=TIME
Format=%#w

[msWeekDay2]
Measure=CALC
Formula=#FirstX#+msWeekDay*FLOOR(#SpacingX#)
EDIT:
SpacingX=(FLOOR((#SidebarWidth#-#FirstX#-19)/6))
This is probably a better idea, and works for me. Round, Ceil are just fine too.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Calendar Date Position Drift

Post by Kaelri »

Aha, Floor did the trick. Rainmeter must simply drop the remainder whenever it's told to use a non-integer for a meter position.

Thanks again, smurfier. :)