Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 904

Help: Rainmeter Skins • Center text

$
0
0
Hey, I have this test skin where I'm changing the size of the text dynamically. It changes its size according to its number of characters.

The problem is that, although I managed to resize the text using a technique I found somewhere in the forums, I can't manage to keep the text centered. I'm out of ideas.

The text will have a maximum of 12 characters and a minimum of 1
it goes from size 35 to size 12
fsa.jpg
fssa.jpg
Captura de pantalla 2024-01-12 023759.jpg
The dark grey rectangle represents the text's height

I did find a solution but it wouldn't do it as good as I want to, so any ideas are welcomed.

What I'm doing right now is: I'm using a measure to count the number of characters

Code:

[Characters]Measure = StringDynamicVariables=1String = [#Text]RegExpSubstitute = 1Substitute = "(?s)^(.{1})$" : "1", "(?s)^(.{2})$" : "2", "(?s)^(.{3})$" : "3", "(?s)^(.{4})$" : "4", "(?s)^(.{5})$" : "5", "(?s)^(.{6})$" : "6", "(?s)^(.{7})$" : "7", "(?s)^(.{8})$" : "8", "(?s)^(.{9})$" : "9", "(?s)^(.{10})$" : "10", "(?s)^(.{11})$" : "11", "(?s)^(.{12})$" : "12", "(?s)^(.{13})$" : "13", "(?s)^(.{14})$" : "14", "(?s)^(.{15})$" : "15", "(?s)^(.{16})$" : "16", "(?s)^(.{17})$" : "17", "(?s)^(.{18})$" : "18", "(?s)^(.{19})$" : "19", "(?s)^(.{20})$" : "20", "(?s)^(.{21})$" : "21", "(?s)^(.{22})$" : "22", "(?s)^(.{23})$" : "23", "(?s)^(.{24})$" : "24", "(?s)^(.{25})$" : "25", "(?s)^(.{26})$" : "26", "(?s)^(.{27})$" : "27", "(?s)^(.{28})$" : "28", "(?s)^(.{29})$" : "29", "(?s)^(.{30})$" : "30", "(?s)^(.{31})$" : "31", "(?s)^(.{32})$" : "32", "(?s)^(.{33})$" : "33", "(?s)^(.{34})$" : "34", "(?s)^(.{35})$" : "35", "(?s)^(.{36})$" : "36", "(?s)^(.{37})$" : "37", "(?s)^(.{38})$" : "38", "(?s)^(.{39})$" : "39", "(?s)^(.{40})$" : "40", "(?s)^(.{41})$" : "41", "(?s)^(.{42})$" : "42", "(?s)^(.{43})$" : "43", "(?s)^(.{44})$" : "44", "(?s)^(.{45})$" : "45", "(?s)^(.{46})$" : "46", "(?s)^(.{47})$" : "47", "(?s)^(.{48})$" : "48", "(?s)^(.{49})$" : "49", "(?s)^(.{50})$" : "50", "(?s)^(.{51})$" : "51", "(?s)^(.{52})$" : "52", "(?s)^(.{53})$" : "53", "(?s)^(.{54})$" : "54", "(?s)^(.{55})$" : "55", "(?s)^(.{56})$" : "56", "(?s)^(.{57})$" : "57", "(?s)^(.{58})$" : "58", "(?s)^(.{59})$" : "59", "(?s)^(.{60})$" : "60", "(?s)^(.{61})$" : "61", "(?s)^(.{62})$" : "62", "(?s)^(.{63})$" : "63", "(?s)^(.{64})$" : "64", "(?s)^(.{65})$" : "65", "(?s)^(.{66})$" : "66", "(?s)^(.{67})$" : "67", "(?s)^(.{68})$" : "68", "(?s)^(.{69})$" : "69", "(?s)^(.{70})$" : "70", "(?s)^(.{71})$" : "71", "(?s)^(.{72})$" : "72", "(?s)^(.{73})$" : "73", "(?s)^(.{74})$" : "74", "(?s)^(.{75})$" : "75", "(?s)^(.{76})$" : "76", "(?s)^(.{77})$" : "77", "(?s)^(.{78})$" : "78", "(?s)^(.{79})$" : "79", "(?s)^(.{80})$" : "80", "(?s)^(.{81})$" : "81", "(?s)^(.{82})$" : "82", "(?s)^(.{83})$" : "83", "(?s)^(.{84})$" : "84", "(?s)^(.{85})$" : "85", "(?s)^(.{86})$" : "86", "(?s)^(.{87})$" : "87", "(?s)^(.{88})$" : "88", "(?s)^(.{89})$" : "89", "(?s)^(.{90})$" : "90", "(?s)^(.{91})$" : "91", "(?s)^(.{92})$" : "92", "(?s)^(.{93})$" : "93", "(?s)^(.{94})$" : "94", "(?s)^(.{95})$" : "95", "(?s)^(.{96})$" : "96", "(?s)^(.{97})$" : "97", "(?s)^(.{98})$" : "98", "(?s)^(.{99})$" : "99", "(?s)^(.{100})$" : "100"
and I have a rectangle and a text, in the text fontsize i'm using this

Code:

FontSize=(35/(clamp([Characters]/3,1,3)))
It divides the number of characters by 3 and clamps it between 1 and 3, and the fontsize is divided by that. That is to keep the size between the range I want. It also makes it not too linear so it starts scaling at 3 or more characters. (StringAlign=Center)

Whatever I need to do, I need to add it to the Y position, so it accounts for the size change. What I did was: (I actually did a lot of tests and this is the closest I got to what I want)

Code:

y=([BG:H]-((((clamp([Characters]*0.3,1,3))-1)*((88-71)/(3-1))+88)-((([#CURRENTSECTION#:H]-51)/(18-51))*(33-0))))
but it won't do exactly what I want, is not perfect.
Even tho the start and the end look good, on the middle it looks like this:
Captura de pantalla 2024-01-12 030204.jpg
Thanks in advance.

Edit.

Well, it seems like the answer is

Code:

y=(Initial Y position) + ((MaxTextHeight-[Text:H])/2)

Statistics: Posted by RicardoTM — Yesterday, 9:07 am — Replies 6 — Views 140



Viewing all articles
Browse latest Browse all 904

Trending Articles