I'll work on a solution for you, but it might have to be later tonight or in the morning.Rambytes wrote:I've read twice the answer of jsmorley and i'm not sure to understand how to split in two meter....
It is currently April 27th, 2024, 12:51 am
Can I "center" my download rate with the «.» ?
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Can I "center" my download rate with the «.» ?
-
- Posts: 27
- Joined: August 30th, 2017, 10:36 pm
Re: Can I "center" my download rate with the «.» ?
My friend TAKE YOUR TIME..... no rush on that... no rush at all
-
- Posts: 826
- Joined: November 20th, 2012, 11:58 pm
Re: Can I "center" my download rate with the «.» ?
I think I found a possible solution, but it works if you use a monospaced font (I used Courier New in this example code)
Let us know what you think.
Code: Select all
[Rainmeter]
Update=500
DynamicWindowSize=1
AccurateText=1
[Metadata]
Name=Testing
Author=FreeRaider
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
[Variables]
OFFSET=-18
[MeasureNetIn]
Measure=NetIn
[MeterDOWNLOAD]
Meter=String
X=0
Y=0
FontFace=Courier New
FontColor=255,255,255,255
StringStyle=Bold
StringAlign=Left
FontSize=24
NumOfDecimals=1
AutoScale=1k
Text="DOWNLOAD"
Antialias=1
DynamicVariables=1
[MeterDOWNLOADrate]
Meter=String
MeasureName=MeasureNetIn
X=( ([MeterDOWNLOAD:W] * 2 + #OFFSET#) /2 )
Y=5R
FontFace=Courier New
FontColor=255,255,255,255
StringStyle=Bold
FontSize=20
StringAlign=RIGHT
NumOfDecimals=1
AutoScale=1k
Text="%1/s"
Antialias=1
DynamicVariables=1
-
- Posts: 27
- Joined: August 30th, 2017, 10:36 pm
Re: Can I "center" my download rate with the «.» ?
OMG......
Ok, dude, you're awesome....
Explain to me this part of the code:
Thanks again!
Ok, dude, you're awesome....
Explain to me this part of the code:
Code: Select all
X=( ([MeterDOWNLOAD:W] * 2 + #OFFSET#) /2 )
Code: Select all
AutoScale=1k
Code: Select all
DynamicVariables=1
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Can I "center" my download rate with the «.» ?
I really still think Lua is a better way to go. It keeps the skin really simple, and to be honest the Lua isn't rocket science either. The trickiest bit is just a canned routine I stole from https://docs.rainmeter.net/snippets/autoscale/.
CenterOnDec.ini:
CenterOnDec.lua:
The decimal point will never move, no matter what is on the left or right side of it, and that is the stated goal. It doesn't care what font or font size you use.
I will let you take a crack at adding what is needed for the NetOut stuff, needless to say is will follow the same approach, with no changes needed to the one-size-fits-all Lua.
Let me know if you have questions. I can walk you through the Lua if you need it.
https://docs.rainmeter.net/manual/lua-scripting/
https://docs.rainmeter.net/manual/lua-scripting/inline-lua/
https://docs.rainmeter.net/manual/variables/nesting-variables/
http://lua-users.org/wiki/MathLibraryTutorial
CenterOnDec.ini:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
Interface=Best
CenterPoint=150
[MeasureNetIn]
Measure=NetIn
Interface=#Interface#
UseBits=1
[Lua]
Measure=Script
ScriptFile=CenterOnDec.lua
Disabled=1
[MeterNetInTrunc]
Meter=String
X=#CenterPoint#
StringAlign=Right
FontSize=15
FontWeight=400
FontColor=255,255,255,255
AntiAlias=1
DynamicVariables=1
Text=[&Lua:SplitScaled([&MeasureNetIn:],'trunc')]
[MeterNetInFrac]
Meter=String
X=#CenterPoint#
StringAlign=Left
FontSize=15
FontWeight=400
FontColor=255,255,255,255
AntiAlias=1
DynamicVariables=1
Text=.[&Lua:SplitScaled([&MeasureNetIn:],'frac')]
Code: Select all
function SplitScaled(inVal, whichSide)
valScaled, scaleTxt = AutoScale(inVal,1)
truncValue, fracValue = math.modf(valScaled)
fracValue = Round(fracValue, 1)
fracValue = string.gsub(fracValue, '0.', '')
if whichSide == 'trunc' then
return truncValue
elseif whichSide == 'frac' then
return fracValue..' '..scaleTxt..'b/s'
else
return ''
end
end
function AutoScale(num, idp)
assert(tonumber(num), 'AutoScale expects a number.')
local scales = {'', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'}
local places = idp or 0
local scale = ""
local scaled = 0
for i, v in ipairs(scales) do
if (num < (1024 ^ i)) or (i == #scales) then
scale = v
scaled = Round(num / 1024 ^ (i - 1), places)
break
end
end
return scaled, scale
end
function Round(num, idp)
assert(tonumber(num), 'Round expects a number.')
local mult = 10 ^ (idp or 0)
if num >= 0 then
return math.floor(num * mult + 0.5) / mult
else
return math.ceil(num * mult - 0.5) / mult
end
end
I will let you take a crack at adding what is needed for the NetOut stuff, needless to say is will follow the same approach, with no changes needed to the one-size-fits-all Lua.
Let me know if you have questions. I can walk you through the Lua if you need it.
https://docs.rainmeter.net/manual/lua-scripting/
https://docs.rainmeter.net/manual/lua-scripting/inline-lua/
https://docs.rainmeter.net/manual/variables/nesting-variables/
http://lua-users.org/wiki/MathLibraryTutorial
http://lua-users.org/wiki/StringLibraryTutorialmath.modf
Return the integral and fractional parts of the given number.
> = math.modf(5)
5 0
> = math.modf(5.3)
5 0.3
> = math.modf(-5.3)
-5 -0.3
string.gsub(s, pattern, replace [, n])
This is a very powerful function and can be used in multiple ways. Used simply it can replace all instances of the pattern provided with the replacement. A pair of values is returned, the modified string and the number of substitutions made. The optional fourth argument n can be used to limit the number of substitutions made
You do not have the required permissions to view the files attached to this post.
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Can I "center" my download rate with the «.» ?
Reworked my solution to use Inline Lua, as it makes the Lua a reusable function, and anyway is just simpler and more straight-forward.
P.S. I used "bits" and not the default "bytes" in the display of the Net values, which is consistent with places like speedtest.net, and scaled by 1024 (mebibit or Mib), which is consistent with how Windows deals with "mega". If you want to change this to "bytes", you can remove the UseBits=1 options from the NetIn measure, and change the b/s text in the Lua to B/s. You can scale by 1000 (megabit or Mb) by changing the 1024 in the AutoScale function in the .lua to 1000.
P.S. I used "bits" and not the default "bytes" in the display of the Net values, which is consistent with places like speedtest.net, and scaled by 1024 (mebibit or Mib), which is consistent with how Windows deals with "mega". If you want to change this to "bytes", you can remove the UseBits=1 options from the NetIn measure, and change the b/s text in the Lua to B/s. You can scale by 1000 (megabit or Mb) by changing the 1024 in the AutoScale function in the .lua to 1000.
-
- Posts: 826
- Joined: November 20th, 2012, 11:58 pm
Re: Can I "center" my download rate with the «.» ?
Rambytes wrote:OMG......
Ok, dude, you're awesome....
Explain to me this part of the code:Code: Select all
X=( ([MeterDOWNLOAD:W] * 2 + #OFFSET#) /2 )
Code: Select all
AutoScale=1k
Thanks again!Code: Select all
DynamicVariables=1
You are welcome!
Now
Code: Select all
X=( ([MeterDOWNLOAD:W] * 2 + #OFFSET#) /2 )
Code: Select all
AutoScale=1k
Code: Select all
DynamicVariables=1
Last edited by FreeRaider on August 10th, 2018, 5:06 pm, edited 1 time in total.
-
- Posts: 27
- Joined: August 30th, 2017, 10:36 pm
Re: Can I "center" my download rate with the «.» ?
FreeRaider, and ALL the OTHER, thanks a lot...... very very very appreciated!!!!!
-
- Posts: 826
- Joined: November 20th, 2012, 11:58 pm
Re: Can I "center" my download rate with the «.» ?
Glad to help.