Appling TransformationMatrix on a Shape meter

Report bugs with the Rainmeter application and suggest features.
User avatar

Appling TransformationMatrix on a Shape meter

September 28th, 2017, 4:48 pm
balala
Rainmeter Sage   [4985 posts]

Hi everyone,

It seems again came the time to ask something. My question is about the TransformationMatrix option, applied to the new Shape meter. Last days I worked with a such meter and wanted to rotate it, using a TransformationMatrix option. On the Transformation Matrix Guide description of the Tips & Tricks section of help, we have a very good description of how to rotate the meters. I applied the described method many time on many kind of meters (especially String and Image). But now, when I tried to use the same method on a Shape meter, it behaved totally different then the String or Image meters.
Let me show you a simple code:

Code: Select all

[Rainmeter]
Update=-1
BackgroundMode=2
SolidColor=80,80,80,160
SkinWidth=300
SkinHeight=300
LeftMouseUpAction=[!CommandMeasure "MeasureFalling" "Execute 1"]

[Variables]
Angle=0
XPos=50
YPos=20
Upd=[!UpdateMeasure "MeasureFalling"][!UpdateMeterGroup "Elements"][!UpdateMeter "MeterAngle"][!Redraw]

[MeasureFalling]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Work,75,10
Work=[!SetVariable Angle "(Clamp((#Angle#+9),0,90))"]#Upd#
DynamicVariables=1

[MeterRotate1]
Meter=Image
SolidColor=255,240,0
X=#XPos#
Y=#YPos#
W=5
H=200
DynamicVariables=1
TransformationMatrix=(Cos(Rad(-#Angle#)));(-Sin(Rad(-#Angle#)));(Sin(Rad(-#Angle#)));(Cos(Rad(-#Angle#)));(([MeterRotate1:X]+[MeterRotate1:W]/2)-(([MeterRotate1:X]+[MeterRotate1:W]/2)*Cos(Rad(-#Angle#)))-(([MeterRotate1:Y]+[MeterRotate1:H])*Sin(Rad(-#Angle#))));(([MeterRotate1:Y]+[MeterRotate1:H])+(([MeterRotate1:X]+[MeterRotate1:W]/2)*Sin(Rad(-#Angle#)))-(([MeterRotate1:Y]+[MeterRotate1:H])*Cos(Rad(-#Angle#))))
Group=Elements

[MeterRotate2]
Meter=Shape
Shape=Rectangle 0,0,5,200 | Fill Color 255,0,0 | StrokeWidth 0 | Stroke Color 0,0,0,0
X=0r
Y=0r
DynamicVariables=1
TransformationMatrix=(Cos(Rad(-#Angle#)));(-Sin(Rad(-#Angle#)));(Sin(Rad(-#Angle#)));(Cos(Rad(-#Angle#)));(([MeterRotate2:X]+[MeterRotate2:W]/2)-(([MeterRotate2:X]+[MeterRotate2:W]/2)*Cos(Rad(-#Angle#)))-(([MeterRotate2:Y]+[MeterRotate2:H])*Sin(Rad(-#Angle#))));(([MeterRotate2:Y]+[MeterRotate2:H])+(([MeterRotate2:X]+[MeterRotate2:W]/2)*Sin(Rad(-#Angle#)))-(([MeterRotate2:Y]+[MeterRotate2:H])*Cos(Rad(-#Angle#))))
Group=Elements

[MeterAngle]
Meter=STRING
X=5
Y=5
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=#Angle#
DynamicVariables=1

There are two meters with the same size and in the same position: [MeterRotate1] and [MeterRotate2]:
Image
The first is an Image meter, the second one is a Shape meter. They are differently colored, to can distinguish them. When you click to the background of the skin, both meters are rotated with 90 degrees clockwise. But after the rotation the will get different positions. Like they wouldn't be rotated around the same point:
Image
The TransformationMatrix options are similar, so the rotation should be also similar. Why is happening this and how could be made the Shape meter to rotate same way as the Image meter does? Am I missing something obvious?
Although I posted this question here to the Bugs & Feature Suggestions thread, I'm not sure this is a bug. But I couldn't figure out what to do to make the meter to rotate "normally", like an Image meter does, for example, although I can say I have some experience working with the TransformationMatrix option.

Thanks in advance to anyone could help.
User avatar

Re: Appling TransformationMatrix on a Shape meter

September 28th, 2017, 6:03 pm
eclectic-tech
Rainmeter Sage   [2325 posts]

Just asking... Why use TransformationMatrix on a shape meter, it already has transformers?

Using Rotate parameter on the shape and setting the rotation axis point to the height and half the width gives the same results.

Code: Select all

[Rainmeter]
Update=-1
BackgroundMode=2
SolidColor=80,80,80,160
SkinWidth=300
SkinHeight=300
LeftMouseUpAction=[!CommandMeasure "MeasureFalling" "Execute 1"]

[Variables]
Angle=0
XPos=0
YPos=0
Upd=[!UpdateMeasure "MeasureFalling"][!UpdateMeterGroup "Elements"][!UpdateMeter "MeterAngle"][!Redraw]

[MeasureFalling]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Work,75,10
Work=[!SetVariable Angle "(Clamp((#Angle#+9),0,90))"]#Upd#
DynamicVariables=1

[MeterRotate1]
Meter=Image
SolidColor=255,240,0
X=#XPos#
Y=#YPos#
W=15
H=200
DynamicVariables=1
TransformationMatrix=(Cos(Rad(-#Angle#)));(-Sin(Rad(-#Angle#)));(Sin(Rad(-#Angle#)));(Cos(Rad(-#Angle#)));(([MeterRotate1:X]+[MeterRotate1:W]/2)-(([MeterRotate1:X]+[MeterRotate1:W]/2)*Cos(Rad(-#Angle#)))-(([MeterRotate1:Y]+[MeterRotate1:H])*Sin(Rad(-#Angle#))));(([MeterRotate1:Y]+[MeterRotate1:H])+(([MeterRotate1:X]+[MeterRotate1:W]/2)*Sin(Rad(-#Angle#)))-(([MeterRotate1:Y]+[MeterRotate1:H])*Cos(Rad(-#Angle#))))
Group=Elements

[MeterRotate2]
Meter=Shape
Shape=Rectangle 0,0,15,200 | Fill Color 255,0,0 | StrokeWidth 0 | Stroke Color 0,0,0,0 | Rotate #Angle#,([MeterRotate1:W]/2),200
X=r
Y=r
DynamicVariables=1
;TransformationMatrix=(Cos(Rad(-#Angle#)));(-Sin(Rad(-#Angle#)));(Sin(Rad(-#Angle#)));(Cos(Rad(-#Angle#)));(([MeterRotate2:X]+[MeterRotate2:W]/2)-(([MeterRotate2:X]+[MeterRotate2:W]/2)*Cos(Rad(-#Angle#)))-(([MeterRotate2:Y]+[MeterRotate2:H])*Sin(Rad(-#Angle#))));(([MeterRotate2:Y]+[MeterRotate2:H])+(([MeterRotate2:X]+[MeterRotate2:W]/2)*Sin(Rad(-#Angle#)))-(([MeterRotate2:Y]+[MeterRotate2:H])*Cos(Rad(-#Angle#))))
Group=Elements

[MeterAngle]
Meter=STRING
X=5
Y=5
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=#Angle#
DynamicVariables=1
User avatar

Re: Appling TransformationMatrix on a Shape meter

September 28th, 2017, 6:46 pm
balala
Rainmeter Sage   [4985 posts]

eclectic-tech wrote:Just asking... Why use TransformationMatrix on a shape meter, it already has transformers?

Because I had no idea about this possibility. Your idea is indeed very good and at a first look seems that the Shape meter indeed can be rotated well with this option. Now after you've posted your reply, I remember I read once about this but couldn't remember it.
Thanks eclectic-tech, great help. :thumbup:

However, even so, my question still remains: why a Shape meter behaves differently then any other meter when the TransformationMatrix is applied? Finally the TransformationMatrix isn't limited to the rotation, it can do much much more then rotate the meter. So maybe sometimes still should be used.
User avatar

Re: Appling TransformationMatrix on a Shape meter

September 28th, 2017, 7:12 pm
eclectic-tech
Rainmeter Sage   [2325 posts]

balala wrote:... However, even so, my question still remains: why a Shape meter behaves differently then any other meter when the TransformationMatrix is applied? Finally the TransformationMatrix isn't limited to the rotation, it can do much much more then rotate the meter. So maybe sometimes still should be used.

Perhaps one of Devs can weigh in on that.

It has something to do with the X & Y setting on the image meter versus the X & Y settings on the shape meter; if you set those to zero for both meters, the TranformationMatrix works the same. Once you change the X & Y values away from zero, the TransformationMatrix works differently on the shape meter. :?

The shape meter transformers can do everything the 'matrix' does, and it uses generic terms rather than formulas, so for me it is easier to use. :D
User avatar

Re: Appling TransformationMatrix on a Shape meter

September 28th, 2017, 7:29 pm
balala
Rainmeter Sage   [4985 posts]

eclectic-tech wrote:It has something to do with the X & Y setting on the image meter versus the X & Y settings on the shape meter; if you set those to zero for both meters, the TranformationMatrix works the same. Once you change the X & Y values away from zero, the TransformationMatrix works differently on the shape meter. :?

Right! I also figured this out.
eclectic-tech wrote:The shape meter transformers can do everything the 'matrix' does, and it uses generic terms rather than formulas, so for me it is easier to use. :D

What is the easiest depends I think on the user. For me the TransformationMatrix is an easy thing, the involved math isn't so hard as many users think. I've invested a lot of time over last years to figure out how does it work, but finally I think I can use it easily. But as I think you saw, the Shape meter is still unusual for me and have to get used to it. Probably I will in the future...
User avatar

Re: Appling TransformationMatrix on a Shape meter

October 9th, 2017, 7:53 pm
Brian
Developer   [1591 posts]

Thanks for reporting. We believe this issue to be fixed for the next beta.

[Technical_Details]
The problem here is the order in which we were applying transforms to shapes. The shape meter supports additional transform options that need to be applied to the shape before drawing it. We also apply a 'translate' matrix to move the shape to the correct position defined by the X/Y of the meter. So we are dealing with 3 different matrices here and were applying them in the following order: Shape transforms, 'world' transforms (from TransformationMatrix), and the translate matrix. The problem is that translated coordinates needed to be applied before the world matrix (TransformationMatrix).
[/Technical_Details]

-Brian
User avatar

Re: Appling TransformationMatrix on a Shape meter

October 9th, 2017, 8:42 pm
balala
Rainmeter Sage   [4985 posts]

Brian wrote:Thanks for reporting. We believe this issue to be fixed for the next beta.

Great Brian. I understood your explanation and wait for the next beta. Although the issue is at least partially fixed by eclectic-tech's suggestion, I'm still curious how will it work.
Many thanks.
User avatar

Re: Appling TransformationMatrix on a Shape meter

October 12th, 2017, 3:53 pm
balala
Rainmeter Sage   [4985 posts]

It seems the new version (r2944), published today (Oct 12), indeed fixed the issue.
Many thanks.

Return to “Bugs & Feature Suggestions”



Who is online

Users browsing this forum: No registered users and 2 guests