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

Help: Rainmeter Skins • Re: RecycleBin string issue

$
0
0
I agree with balala here, it's hard to understand what you're after. In any case, to give you an idea of what it would take to use a "custom autoscale":
But I can't have both using the same scaling with AutoScale. The BinSize requires AutoScale=1, whereas BinItems requires AutoScale=2.
Here is the original - and ingenious - method by smurfier:
https://forum.rainmeter.net/viewtopic.php?t=17656#p97070
Code after corrections:

Code:

[Variables]Decimals=2[num]Measure=CalcFormula=1563154794265[Scale]Measure=CalcFormula=(num=0?1:ceil(log(num)/(10*log(2))))Substitute="1":"B","2":"kB","3":"mB","4":"gB","5":"tB","6":"pB","7":"eB","8":"zB","9":"yB"[Scaled]Measure=CalcFormula=round(num/1024**(Scale-1),#Decimals#)[String]Meter=StringSolidColor=0,255,0,255MeasureName=ScaledNumOfDecimals=#Decimals#Text=%1 [Scale]DynamicVariables=1
Here is my improved and more flexible variant based on the same approach:
https://forum.rainmeter.net/viewtopic.php?t=38190&start=20#p198261
Code after corrections:

Code:

[Variables]Scale=1024Decimals=2[Rainmeter]Update=1000DynamicWindowSize=1AccurateText=1BackgroundMode=2SolidColor=47,47,47,255---Measures---[Value]Measure=CalcFormula=1563154794265UpdateDivider=-1DynamicVariables=1[ValueAutoScaled]Measure=CalcFormula=Sgn(Value=0?1:Value)*(Round(Abs(Value)/#Scale#**Trunc(Log(Abs(Value)<1?1:Abs(Value))/Log(#Scale#)),#Decimals#)+(Trunc(Log(Abs(Value)<1?1:Abs(Value))/Log(#Scale#))+1)*(10**(-#Decimals#-2)))UpdateDivider=-1RegExpSubstitute=1Substitute="^(.*\..{#Decimals#}).{1}(.{1}).*$":"\1\2","1$":"  ","2$":" K","3$":" M","4$":" G","5$":" T","6$":" P","7$":" E","8$":" Z","9$":" Y"DynamicVariables=1---Meters---[MeterTest]Meter=StringFontFace=ConsolasFontColor=255,255,255,255SolidColor=47,47,47,255Padding=5,5,5,5FontSize=16AntiAlias=1Text="Value = [Value] ([ValueAutoScaled]B)"UpdateDivider=-1DynamicVariables=1
The difference is that smurfier variant is easier to understand but it used a fixed 1024 scale, while my variant tries to cover any scale, both positive and negative numbers, and do everything in a single measure, by storing the "scale" part as the last fractional digit of the number, which is then converted to the ' K', ' M', ' G' and so on strings (thus, the number of decimals is limited to a maximum of 4, since the 5th is "reserved" for the scale digit / indicator). The math is based on the definition of logarithms as inverses of exponential functions, so basically you can get to which power the said scale has to be raised at to give the original number. Simple example for base 10: log 10 3576 = 3.5534, which means 3576 has 1 + 3 digits where 3 is the powers of 10 that you multiply 3.576 with to get the value, or the fact that 10^3.5534 = 3576.

P.S. Also, the above uses the property / identity according to which log A B = log 10 B / log 10 A.

EDIT: Corrected the identity above.

Statistics: Posted by Yincognito — Yesterday, 9:53 pm



Viewing all articles
Browse latest Browse all 1486

Trending Articles