It is currently September 14th, 2024, 9:58 pm

Working with Angle on a String Meter (redux)

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
Yincognito
Rainmeter Sage
Posts: 8127
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Working with Angle on a String Meter (redux)

Post by Yincognito »

jsmorley wrote: September 13th, 2014, 4:28 pm As you can see, this will make positioning a bit tricky, as while X works fine, the center of rotation is also based on where Y (the top) is defined for the meter, and there is really no way to have the anchor be actually in the vertical "middle" of the text string.
Well, since I (thought that I) needed it in one of my codes, here is the way - it's actually quite simple if you draw things on a piece of paper:

Code: Select all

[Rainmeter]
Update=100
AccurateText=1
DynamicWindowSize=1

[MeasureRotate]
Measure=Calc
Formula=(MeasureRotate % 360) + 10

[MeterBack]
Meter=Image
W=100
H=100
SolidColor=47,47,47,255

[MeterOne]
Meter=String
X=50
Y=50
StringAlign=CenterCenter
FontSize=12
FontColor=0,0,0,0
SolidColor=255,150,150,128
AntiAlias=1
Text=Hello World

[MeterTwo]
Meter=String
X=(50+[MeterTwo:W]*0.5*0+[MeterTwo:H]*0.5*Cos(Rad([MeasureRotate]-90)))
Y=(50+[MeterTwo:H]*0.5*1+[MeterTwo:H]*0.5*Sin(Rad([MeasureRotate]-90)))
StringAlign=CenterCenter
FontSize=12
FontColor=255,255,255,255
SolidColor=150,150,150,128
AntiAlias=1
Text=Hello World
Angle=(Rad([MeasureRotate]))
DynamicVariables=1
Desktop_2024_08_17_21_08_16_340-ezgif.com-optimize.gif
Some parts of the X and Y formulas can be canceled, of course - I let them like that so that every one of them is clear. This seems to work without requiring changes for most if not all string alignments. Didn't test other fonts, but I reckon the 0.5 factor of [MeterTwo:H] will have to be adjusted for fonts where the text is higher or lower than the absolute middle in the meter area. White is the adjusted meter area, red is the reference meter area.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5511
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Working with Angle on a String Meter (redux)

Post by eclectic-tech »

"Wizardry" :twisted: ;-) 8-)

Who uses pen and paper anymore?
User avatar
balala
Rainmeter Sage
Posts: 16539
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Working with Angle on a String Meter (redux)

Post by balala »

Definitely agree that there (almost) always are different ways to get the same result, but in my opinion (once again: IN MY OPINION) this approach is complicated enough. Not sure it worth. TransformationMatrix seems much more easy in my opinion.
Yep, I know lot of people now will want to behead me for this, but this is my though. Don't want to underestimate what Yincognito did, definitely is a good approach, but seems way complicated.
User avatar
sl23
Posts: 1667
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Working with Angle on a String Meter (redux)

Post by sl23 »

eclectic-tech wrote: August 17th, 2024, 8:08 pm "Wizardry" :twisted: ;-) 8-)

Who uses pen and paper anymore?
Just a quick question...

What's pen and paper? :confused:
57686174 77696C6C 6265 77696C6C 6265
User avatar
Yincognito
Rainmeter Sage
Posts: 8127
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Working with Angle on a String Meter (redux)

Post by Yincognito »

eclectic-tech wrote: August 17th, 2024, 8:08 pm "Wizardry" :twisted: ;-) 8-)

Who uses pen and paper anymore?
Well, wizards do... to write their spells so that they won't forget them. :lol:
Joking aside, it comes much easier for me to do a little sketch on paper to visualize a problem, than to use any drawing software.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 8127
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Working with Angle on a String Meter (redux)

Post by Yincognito »

balala wrote: August 17th, 2024, 8:23 pmbut seems way complicated
Not sure there's anything more complicated than the transformation matrix in Rainmeter if you ask 10 people out of 10, but I know you have a soft spot for it, so it's understandable. In the end, it's the same math, just put in a different way, so the complexity is factually the same. A simpler form (+0 is just so they look similar):

Code: Select all

X=(50+[MeterTwo:H]/2*(Cos(Rad([MeasureRotate]-90))+0))
Y=(50+[MeterTwo:H]/2*(Sin(Rad([MeasureRotate]-90))+1))
Now if you think this is also complicated... :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16539
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Working with Angle on a String Meter (redux)

Post by balala »

Yincognito wrote: August 17th, 2024, 9:34 pm Not sure there's anything more complicated than the transformation matrix in Rainmeter if you ask 10 people out of 10, but I know you have a soft spot for it, so it's understandable. In the end, it's the same math, just put in a different way, so the complexity is factually the same. A simpler form (+0 is just so they look similar):

Code: Select all

X=(50+[MeterTwo:H]/2*(Cos(Rad([MeasureRotate]-90))+0))
Y=(50+[MeterTwo:H]/2*(Sin(Rad([MeasureRotate]-90))+1))
Now if you think this is also complicated... :confused:
Yep, most probably you are right. Don't really know why people are thinking so, but yep, most probably lot of users do. So, once again, which solution is complicated, depends on lot of things. As said in my reply, the TransformationMatrix related things were my opinion, which I still sustain, but can't and don't even want to impose to anyone.
User avatar
Yincognito
Rainmeter Sage
Posts: 8127
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Working with Angle on a String Meter (redux)

Post by Yincognito »

balala wrote: August 18th, 2024, 7:08 pm Yep, most probably you are right. Don't really know why people are thinking so, but yep, most probably lot of users do. So, once again, which solution is complicated, depends on lot of things. As said in my reply, the TransformationMatrix related things were my opinion, which I still sustain, but can't and don't even want to impose to anyone.
I'm not imposing this on anyone either, it's meant to help others reading the topic, if they'll ever need it. In fact, you can share the transformation matrix solution at any time you want, can or have time for it. I like transformation matrix too and don't think it's overly complicated, I just try to avoid its disadvantages regarding mouse actions or the fact that unfortunately can't do perspective with it. In this case though, these disadvantages don't matter since the meter area doesn't follow the text in the Angle option anyway, so you'd end up with a mismatch in that regard whatever method you'd choose. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16539
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Working with Angle on a String Meter (redux)

Post by balala »

Yincognito wrote: August 18th, 2024, 7:38 pm In this case though, these disadvantages don't matter since the meter area doesn't follow the text in the Angle option anyway, so you'd end up with a mismatch in that regard whatever method you'd choose. ;-)
Right. This is a well-known disadvantage of TransformationMatrix, but same disadvantage is there on the Angle method as well.
Yincognito wrote: August 18th, 2024, 7:38 pm or the fact that unfortunately can't do perspective with it.
Can the Angle method be used to create a perspective of the meter?
User avatar
Yincognito
Rainmeter Sage
Posts: 8127
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Working with Angle on a String Meter (redux)

Post by Yincognito »

balala wrote: August 18th, 2024, 7:46 pmCan the Angle method be used to create a perspective of the meter?
You mean the formulas I used earlier, or the option itself? Of course not, neither of them. ImageMagick / MagickMeter can though, as you probably know.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth