djamman wrote: ↑August 24th, 2021, 8:25 pm
I *think* I am using TransformationMatrix correctly. Integer scale factors are perfect, non-integers (1.2, 1.6, etc) have the ellipse too low. Is the Calendar code suffering from rounding/truncation errors? Again, I can live with it but I am really curious about the root cause.
Doug
WOW, this got complicated, LOL... I think I got it to work perfectly at any scale factor, but it's a pretty hacky approach.
But first, to answer your TranformationMatrix question, you were very close. When you scale a meter, it will "push" the meter slightly out of position, so you need to offset it to get it back precisely into place. What you would need to use is something like
TransformationMatrix=#Scale#;0;0;#Scale#;([#CURRENTSECTION#:X]*(1-#Scale#));([#CURRENTSECTION#:Y]*(1-#Scale#)). If the entire skin was "transformation-matrixed", then you could get away with just using the same expression as the rest of the skin. In this case, you need really precise positioning. Unfortunately, as precise as you want to be, it still won't be good enough. Because the position of a "cell" is some value that is affected by rounding (and made worse by the fact the cells are being positioned using relative positioning instead of explicit X/Y values), there's nothing you can really do to make this approach work. Time for a hack...
What I did is create a measure to calculate which "cell" (meter) is the current day. Fortunately, the LuaCalendar author just named all the meters sequentially. Once I got the "today" meter number, I used a variant of your ellipse code to draw the circle using the exact coordinates of the "today" meter itself, so any "drift" caused by rounding is irrelevant.
Here's the code I used. First, add the following measure as the last measure in the
<Style>Style.inc skin (i.e., GadgetsStyle.inc), just above the meter section of the code. This measure figures out which "mDay
N" meter is "today" and then shows the highlight meter (if needed).
Code: Select all
[CalcMeter]
Measure=Calc
Formula=(#ThisWeek# - 1) * 7 + (#Week# + 1)
IfCondition=(#NotCurrentMonth# = 0) && (CalcMeter > 0) && ([mDay[&CalcMeter]:X] > 0)
IfTrueAction=[!ShowMeter TodayHL]
IfFalseAction=[!HideMeter TodayHL]
DynamicVariables=1
Finally, replace the
[TodayHL] meter with the following:
Code: Select all
[mDay0]
Meter=String
Hidden=1
[TodayHL]
Meter=Shape
Shape=Ellipse ([mDay[&CalcMeter]:X]+(#C.w#/2)), ([mDay[&CalcMeter]:Y]+(#C.h#/2)),(1+#C.w#/2),(1+#C.h#/2) | Fill Color 0,0,0,0 | Strokewidth (Max(2,(1+#Scale#))) | Stroke Color #ColorFontTitle#
Hidden=1
DynamicVariables=1
The
[mDay0] meter is a hidden dummy meter needed because when the skin first loads, the CalcMeter measure returns 0 until things get started up. I tweaked your stroke width code slightly to make the line width scale up with the rest of the skin so everything is proportional.
In the end, I got it so the circles are perfectly centered on the cell; however, because the fonts don't scale precisely, at some scale values the circle will appear slightly low by a pixel or two. It is actually the number that is high. The easiest way to see the "cells" is to add something like
SolidColor=0,255,0,64 to the
[TextStyle] style meter to make them show up.
Does this work OK for you?