It is currently October 26th, 2021, 11:31 am

Rotational + scaling transformation matrix

Help with creating, editing & fixing problems with skins
User avatar
Jax
Posts: 37
Joined: June 7th, 2021, 11:46 am

Rotational + scaling transformation matrix

Post by Jax »

Hello! I am currently trying to create an animation by rotating an image around it's center. There is a guide from the docs, but it seems to use the rotator meter and the image size cannot be dynamically changed. Is there a way to do this with transformation matrix on a image meter? Thanks :welcome:
Deviantart page // My site // Please make a proper settings menu for your skins
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4438
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Rotational + scaling transformation matrix

Post by eclectic-tech »

Yes, you can do this using an image meter (you can resize the image using W & H) and add a TransformationMatrix to the image meter.

Code: Select all

[Rainmeter]
Update=250
SkinWidth=((SQRT((#ImageWidth#**2)+(#ImageHeight#**2)))+(#XOffset#*0.5))
SkinHeight=((SQRT((#ImageWidth#**2)+(#ImageHeight#**2)))+(#YOffset#*0.5))

[Variables]
ImageWidth=160
ImageHeight=160
XOffset=40
YOffset=40
RotationCenterX=(#ImageWidth#*0.5+#XOffset#)
RotationCenterY=(#ImageHeight#*0.5+#YOffset#)
Angle=[loop1]

[Loop1]
Measure=Loop
StartValue=0
EndValue=345
Increment=15
LoopCount=0
InvertMeasure=0

[Image]
Meter=Image
X=#XOffset#
Y=#YOffset#
W=#ImageWidth#
H=#ImageHeight#
SolidColor=247,47,47,200
AntiAlias=1
DynamicVariables=1
TransformationMatrix=(Cos(Rad(#Angle#)));(-Sin(Rad(#Angle#)));(Sin(Rad(#Angle#)));(Cos(Rad(#Angle#)));(#RotationCenterX#-#RotationCenterX#*Cos(Rad(#Angle#))-#RotationCenterY#*Sin(Rad(#Angle#)));(#RotationCenterY#+#RotationCenterX#*Sin(Rad(#Angle#))-#RotationCenterY#*Cos(Rad(#Angle#)))
rotateTM.gif
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 13345
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Rotational + scaling transformation matrix

Post by balala »

Jax wrote: August 12th, 2021, 2:45 am There is a guide from the docs, but it seems to use the rotator meter and the image size cannot be dynamically changed.
It can be, using the same TransformationMatrix. If eclectic-tech's solution doesn't meat your needs and you would like to see how such a TransformationMatrix can be used to resize a Rotator meter, please let me know.
User avatar
Jax
Posts: 37
Joined: June 7th, 2021, 11:46 am

Re: Rotational + scaling transformation matrix

Post by Jax »

Thanks eclectic-tech for your solution! This helped me out a lot :D

balala wrote: August 12th, 2021, 11:12 am It can be, using the same TransformationMatrix. If eclectic-tech's solution doesn't meat your needs and you would like to see how such a TransformationMatrix can be used to resize a Rotator meter, please let me know.
Rotator meter's flexibility for me is a bit low, so I won't be using that. Thanks for the offer though balala :great:
Deviantart page // My site // Please make a proper settings menu for your skins
User avatar
balala
Rainmeter Sage
Posts: 13345
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Rotational + scaling transformation matrix

Post by balala »

Jax wrote: August 12th, 2021, 1:35 pm Rotator meter's flexibility for me is a bit low, so I won't be using that. Thanks for the offer though balala :great:
As you wish. You're welcome.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Rotational + scaling transformation matrix

Post by death.crafter »

eclectic-tech wrote: August 12th, 2021, 3:46 am
I am really a noob at tm.

So, isn't tm relative to meter position?
from the Realm of Death
My Current Desktop
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4438
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Rotational + scaling transformation matrix

Post by eclectic-tech »

death.crafter wrote: August 28th, 2021, 9:58 am I am really a noob at tm.

So, isn't tm relative to meter position?
I'm no expert on TM either. but the answer to your question is 'yes', it is relative to 1 fixed point in the meter defined by Tx and Ty values. By default it is the upper left corner.
Have a look at these TM examples: https://forum.rainmeter.net/viewtopic.php?f=119&t=29750&p=153848&hilit=scaling#p153841 they scale from the upper left corner or from the center point.

Correction: Balala is right, the TM is relative to 0,0 position in the SKIN (in configs with only 1 meter, that is the same point).
User avatar
SilverAzide
Rainmeter Sage
Posts: 1629
Joined: March 23rd, 2015, 5:26 pm

Re: Rotational + scaling transformation matrix

Post by SilverAzide »

eclectic-tech wrote: August 28th, 2021, 1:54 pm I'm no expert on TM either. but the answer to your question is 'yes', it is relative to 1 fixed point in the meter defined by Tx and Ty values. By default it is the upper left corner.
Have a look at these TM examples: https://forum.rainmeter.net/viewtopic.php?f=119&t=29750&p=153848&hilit=scaling#p153841 they scale from the upper left corner or from the center point.
Ack! I wish I would have seen that TM post 4 years ago! It should be pinned at the top of the forum, if not for the examples then for the Invader Zim reference.
Gadgets Wiki GitHub More Gadgets...
User avatar
balala
Rainmeter Sage
Posts: 13345
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Rotational + scaling transformation matrix

Post by balala »

death.crafter wrote: August 28th, 2021, 9:58 am So, isn't tm relative to meter position?
Actually not:
Every transformation you do will always be relative to the origin. That's the point with coordinates (0,0).
See the What the heck is Rainmeter doing?! section of the Transformation Matrix Guide.