It is currently April 20th, 2024, 1:13 pm

Help with "Bar Meter" and how to curve

Get help with creating, editing & fixing problems with skins
User avatar
BlueJive
Posts: 27
Joined: February 25th, 2021, 6:45 am

Help with "Bar Meter" and how to curve

Post by BlueJive »

Hi all!

Hope it's okay to post more than once in a day... I'm having some issues with the bar meter.

Here is how it is looking now (it is a widget to measure battery levels):

Image

You can see it is a straight rectangle, however I would like it to look like this:

Image

Is this possible with rainmeter? Curving a bar meter? Or will I have to create an image instead, rather than coding it? This is preferably not how I would like to do it. I am constantly making updates to my configuration and I'd rather edit the code than having to edit an image every time I want to change it.

Here is my code if it helps (by the way, I have a sneaking suspicion that it does not actually work, it never seems to change):

Code: Select all

[Shape 1]
Meter=Shape
Shape=Rectangle 540,0,110,8,5 | Fill Color 61, 70, 87 | StrokeWidth 0

;This is just the curved rectangle that I would like it to look like
;[Shape 2]
;Meter=Shape
;Shape=Rectangle 540,0,90,8,5 | Fill Color 160, 209, 170 | StrokeWidth 0

[MeterBar]
MeasureName=MeasurePower
Meter=BAR
X=542
W=180
H=8
BarOrientation=HORIZONTAL
BarColor=160, 209, 170

[Rainmeter]
Update=1000

[MeasurePower]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=PERCENT
UpdateDivider=10
Any help appreciated, and for information, here's my system info:

Thanks! And have a nice day :welcome:
Last edited by BlueJive on February 28th, 2021, 5:26 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with "Bar Meter" and how to curve

Post by balala »

BlueJive wrote: February 25th, 2021, 9:26 am Is this possible with rainmeter? Curving a bar meter? Or will I have to create an image instead, rather than coding it?
No, curving a Bar meter is definitely not possible, but you can use instead a properly created Shape meter. Here is an example based on your code. Just replace the [MeterBar] meter with the following one:

Code: Select all

[MeterBarShape]
Meter=Shape
X=542
Y=0
Shape=Rectangle 0,0,180,8,4 | Extend MyModifiers2
Shape2=Rectangle 0,0,(1.8*[MeasurePower]),8,4 | Extend MyModifiers1
MyModifiers1=Fill Color 160,209,170 | StrokeWidth 0 | Stroke Color 0,0,0,0
MyModifiers2=Fill Color 61,70,87 | StrokeWidth 0 | Stroke Color 0,0,0,0
DynamicVariables=1
User avatar
BlueJive
Posts: 27
Joined: February 25th, 2021, 6:45 am

Re: Help with "Bar Meter" and how to curve

Post by BlueJive »

Thank you! That seems to be working, I'll mark this as solved.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with "Bar Meter" and how to curve

Post by balala »

BlueJive wrote: February 25th, 2021, 10:12 am Thank you! That seems to be working, I'll mark this as solved.
Alright, but don't hurry. Some improvements are still needed. In your code the [MeasurePower] measure is returning a number in the 0 - 100 range, but what if you want to use the Shape meter to show the value of a measure which can vary in a different range? Or maybe you sooner or later will want to change the size of the bar.
To make a much more generally usable rounded "Bar" meter, you have to modify it a little bit. For instance add the following variables and replace once again the code of the meter with the following one. As you probably figured it out, Width and Height are representing the size of the bar, while BarColor and BackgroundColor are representing the colors used onto the bar and its background. You can play with these variables, in order to get a Bar according to your needs in any case.

Code: Select all

[Variables]
Width=180
Height=18
BarColor=160,209,170
BackgroundColor=61,70,87

[MeterBarShape]
Meter=Shape
X=542
Y=0
Shape=Rectangle 0,0,#Width#,#Height#,(#Height#/2) | Extend MyModifiers2
Shape2=Rectangle 0,0,(#Width#*([MeasurePower]-[MeasurePower:MinValue]*(([MeasurePower:MaxValue]-[MeasurePower:MinValue]-[MeasurePower])/([MeasurePower:MaxValue]-[MeasurePower:MinValue])))/([MeasurePower:MaxValue]-[MeasurePower:MinValue])),#Height#,(#Height#/2) | Extend MyModifiers1
MyModifiers1=Fill Color #BarColor# | StrokeWidth 0 | Stroke Color 0,0,0,0
MyModifiers2=Fill Color #BackgroundColor# | StrokeWidth 0 | Stroke Color 0,0,0,0
DynamicVariables=1
User avatar
BlueJive
Posts: 27
Joined: February 25th, 2021, 6:45 am

Re: Help with "Bar Meter" and how to curve

Post by BlueJive »

Brilliant, just brilliant. Thanks.

I had gotten it working previously. But since I'll be "soft" releasing my suite to a handful of friends, this will be rather helpful in making the code easier to understand.
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with "Bar Meter" and how to curve

Post by balala »

BlueJive wrote: February 25th, 2021, 5:48 pm But since I'll be "soft" releasing my suite to a handful of friends, this will be rather helpful in making the code easier to understand.
Not sure it is easier to understand, but at leats I hope it does work in any circumstance. Glad if you like it.