It is currently March 28th, 2024, 11:36 pm

SolidColor, ClipString and Angle

Get help with creating, editing & fixing problems with skins
User avatar
deXxterlab97
Posts: 93
Joined: February 5th, 2017, 4:50 am

SolidColor, ClipString and Angle

Post by deXxterlab97 »

I have a string that displays a random quote every minute and have solidcolor as a background with clipstring=2. Problem is the solidcolor won't rotate if I set angle to the string. How would I solve it?
deXxterlab97
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: SolidColor, ClipString and Angle

Post by FreeRaider »

User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: SolidColor, ClipString and Angle

Post by balala »

deXxterlab97 wrote:I have a string that displays a random quote every minute and have solidcolor as a background with clipstring=2. Problem is the solidcolor won't rotate if I set angle to the string. How would I solve it?
Or beside FreeRaider's reply you could try to replace the Angle option with TransformationMatrix, which can be used for many things, between others, to rotate the meters. So remove the Angle option and add the following one to the meter which has to be rotated:

Code: Select all

TransformationMatrix=(cos(Rad(#Angle#)));(-sin(Rad(#Angle#)));(sin(Rad(#Angle#)));(cos(Rad(#Angle#)));(([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)-([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*cos(Rad(#Angle#))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*sin(Rad(#Angle#)));(([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)+([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*sin(Rad(#Angle#))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*cos(Rad(#Angle#)))
If you added this option, you also have to add an Angle variable to the [Variables] section. Obviously this variable represents the rotation angle, in degrees.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: SolidColor, ClipString and Angle

Post by jsmorley »

balala wrote:Or beside FreeRaider's reply you could try to replace the Angle option with TransformationMatrix, which can be used for many things, between others, to rotate the meters. So remove the Angle option and add the following one to the meter which has to be rotated:

Code: Select all

TransformationMatrix=(cos(Rad(#Angle#)));(-sin(Rad(#Angle#)));(sin(Rad(#Angle#)));(cos(Rad(#Angle#)));(([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)-([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*cos(Rad(#Angle#))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*sin(Rad(#Angle#)));(([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)+([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*sin(Rad(#Angle#))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*cos(Rad(#Angle#)))
If you added this option, you also have to add an Angle variable to the [Variables] section. Obviously this variable represents the rotation angle, in degrees.
Balala, a couple of questions on this, since I am no TransformationMatirx expert...

1) What is the "anchor" point for this rotation? Is it exactly the top left of the existing meter, like Angle on a String meter is? It feels like it "offsets" slightly differently than Angle does, although I guess very close.

2) This particular math formulation seems to be the opposite of Angle on a String meter. Negative angle in degrees (really radians) rotates in a clockwise direction, where Angle would rotate in a counter-clockwise direction with a negative number of radians.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: SolidColor, ClipString and Angle

Post by jsmorley »

The "anchor" does seem to be the same, never mind on that question... Looks like there might be a tiny, 1 or 2 pixel, difference in how Padding is handled.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: SolidColor, ClipString and Angle

Post by balala »

jsmorley wrote:1) What is the "anchor" point for this rotation? Is it exactly the top left of the existing meter, like Angle on a String meter is? It feels like it "offsets" slightly differently than Angle does.
As I wrote the option, the anchor point is the center of the meter. In the above formula(s) I used the ([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2) and ([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2) coordinates to set the anchor point, which mean exactly the center of the meter, regardless where is it positioned. If you'd like for example to rotate it around its top left corner, the above parts of the TransformationMatrix option should have to be replaced by [#CURRENTSECTION#:X] and [#CURRENTSECTION#:Y], accordingly. But obviously any other point inside or outside of the meter can be set as anchor point.
jsmorley wrote:2) This particular math formulation seems to be the opposite of Angle on a String meter. Negative angle in degrees (really radians) rotates in a clockwise direction, where Angle would rotation in a counter-clockwise direction with a negative number of radians.
These form of the option rotates the meter anticlockwise if the angle is positive and clockwise if it's negative. This is indeed opposite of the Angle option, but if you want to change it to have the same rotation direction as with the Angle option, you just have to replace all occurances of the #Angle# variable within the above TransformationMatrix, with -#Angle#. Something like this:

Code: Select all

TransformationMatrix=(cos(Rad(-#Angle#)));(-sin(Rad(-#Angle#)));(sin(Rad(-#Angle#)));(cos(Rad(-#Angle#)));(([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)-([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*cos(Rad(-#Angle#))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*sin(Rad(-#Angle#)));(([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)+([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*sin(Rad(-#Angle#))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*cos(Rad(-#Angle#)))
With this option you have the same rotation directions as with the Angle option: clockwise for positive angles and anticlockwise for negative angles.
jsmorley wrote:The "anchor" does seem to be the same, never mind on that question... Looks like there might be a tiny, 1 or 2 pixel, difference in how Padding is handled.
Well, I have to admit, I didn't follow how the Padding is handled. Will take a look...

TransformationMatrix is a very powerful option (at least in my opinion) when we are talking about rotation (and not just). The math behind it isn't easy, but finally nor impossible isn't to be followed.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: SolidColor, ClipString and Angle

Post by jsmorley »

Balala,

Ok, thanks. It 's a bit unfortunate that it calculates a positive angle as counter-clockwise, as that's not terribly intuitive.

I'm only asking all this because I'd like to create some kind of "tips and tricks", but would like it to be as easy to understand as is possible. Not that it ever will be really...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: SolidColor, ClipString and Angle

Post by jsmorley »

It's possible that the small difference in the X and Y offset that I see with Padding is due to the fact that you are rotating around the center of the meter, which may or may not be equally divisible by 2. If I rotate it around the top left of the meter, that issue seems to go away.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: SolidColor, ClipString and Angle

Post by balala »

jsmorley wrote:Ok, thanks. It 's a bit unfortunate that it calculates a positive angle as counter-clockwise, as that's not terribly intuitive.
Yep, but this isn't a very big problem I think, because using the angles with a minus (as I wrote above) changes the rotation direction.
jsmorley wrote:I'm only asking all this because I'd like to create some kind of "tips and tricks", but would like it to be as easy to understand as is possible. Not that it ever will be really...
About the TransformationMatrix? If so, I'm not sure if it worth, because the Transformation Matrix Guide in the Tips & Tricks section is very good, I think.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: SolidColor, ClipString and Angle

Post by jsmorley »

In the case of a simple String meter, I see no difference in having the anchor point be the top left or the center, other than that "rounding" issue with rotating from the center (meter width / 2).