It is currently March 28th, 2024, 11:36 pm
SolidColor, ClipString and Angle
-
- Posts: 93
- Joined: February 5th, 2017, 4:50 am
SolidColor, ClipString and Angle
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
-
- Posts: 826
- Joined: November 20th, 2012, 11:58 pm
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: SolidColor, ClipString and Angle
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: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?
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#)))
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: SolidColor, ClipString and Angle
Balala, a couple of questions on this, since I am no TransformationMatirx expert...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: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.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#)))
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.
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: SolidColor, ClipString and Angle
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.
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: SolidColor, ClipString and Angle
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: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.
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: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.
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#)))
Well, I have to admit, I didn't follow how the Padding is handled. Will take a look...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.
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.
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: SolidColor, ClipString and Angle
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...
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...
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: SolidColor, ClipString and Angle
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.
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: SolidColor, ClipString and Angle
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:Ok, thanks. It 's a bit unfortunate that it calculates a positive angle as counter-clockwise, as that's not terribly intuitive.
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.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...
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: SolidColor, ClipString and Angle
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).