It is currently March 28th, 2024, 8:40 am

Shape meter - Change color with !SetOption bang?

Get help with installing and using Rainmeter.
Post Reply
CrazyFrog
Posts: 2
Joined: June 24th, 2017, 5:10 pm

Shape meter - Change color with !SetOption bang?

Post by CrazyFrog »

Hello,

can someone tell me if it is possible to change color of Shape meter (Fill Color & Stroke Color) with Bangs?

I've just made this simple code for testing and, as you can see, I can change color of Roundline meter with !SetOption bang, but if I try to change color of Shape meter nothing happens. I know Shape meter is quite new thing and maybe something is not working yet or I'm doing something wrong? I'm quite new to this so maybe I missed something. I have last beta version 4.1 r2815.
shapetest.gif

Code: Select all

[Rainmeter]
Update=1000
SkinWidth=110
SkinHeight=50
BackgroundMode=2
SolidColor=100,100,100

[Variables]
Switch=0

[Measure_String]
Measure=String
String=#Switch#
DynamicVariables=1
IfCondition=(Measure_String = 0)
IfTrueAction=[!SetOption Meter_Roundline LineColor 0,255,0,255][!SetOption Meter_Shape FillColor 0,255,0,255][!SetVariable Switch "1"][!Redraw]
IfCondition2=(Measure_String = 1)
IfTrueAction2=[!SetOption Meter_Roundline LineColor 255,0,0,255][!SetOption Meter_Shape FillColor 255,0,0,255][!SetVariable Switch "0"][!Redraw]

[Meter_Roundline]
Meter=Roundline
StartAngle=(Rad(0))
LineStart=0
LineLength=20
LineColor=255,255,255,255
Solid=1
AntiAlias=1
X=25
Y=25

[Meter_Shape]
Meter=Shape
Shape=Rectangle 65,5,40,40,10 | FillColor 255,255,255,255 | StrokeWidth 0
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Shape meter - Change color with !SetOption bang?

Post by eclectic-tech »

You cannot change individual parts of the shape description; you would need to change the entire shape description, or use the 'Extend' attribute and modify that value. I added an Extend named 'MyColor', and modified that with the !SetOption bang.

Code: Select all

[Rainmeter]
Update=1000
SkinWidth=110
SkinHeight=50
BackgroundMode=2
SolidColor=100,100,100

[Variables]
Switch=0

[Measure_String]
Measure=String
String=#Switch#
DynamicVariables=1
IfCondition=(Measure_String = 0)
IfTrueAction=[!SetOption Meter_Roundline LineColor 0,255,0,255][!SetOption Meter_Shape MyColor "FillColor 0,255,0,255"][!SetVariable Switch "1"][!Redraw]
IfCondition2=(Measure_String = 1)
IfTrueAction2=[!SetOption Meter_Roundline LineColor 255,0,0,255][!SetOption Meter_Shape MyColor "FillColor 255,0,0,255"][!SetVariable Switch "0"][!Redraw]

[Meter_Roundline]
Meter=Roundline
StartAngle=(Rad(0))
LineStart=0
LineLength=20
LineColor=255,255,255,255
Solid=1
AntiAlias=1
X=25
Y=25

[Meter_Shape]
Meter=Shape
Shape=Rectangle 65,5,40,40,10 | StrokeWidth 0 | Extend MyColor
MyColor=FillColor 255,255,255,255

User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Shape meter - Change color with !SetOption bang?

Post by balala »

You can't change simply the FillColor as you did, because in case of shape meters, FillColor is part of Shape option. So you'll have to change the whole Shape option:

Code: Select all

[Measure_String]
Measure=String
String=#Switch#
DynamicVariables=1
IfCondition=(Measure_String = 0)
IfTrueAction=[!SetOption Meter_Roundline LineColor 0,255,0,255][!SetOption Meter_Shape Shape "Rectangle 65,5,40,40,10 | FillColor 0,255,0,255 | StrokeWidth 0"][!SetVariable Switch "1"][!Redraw]
IfCondition2=(Measure_String = 1)
IfTrueAction2=[!SetOption Meter_Roundline LineColor 255,0,0,255][!SetOption Meter_Shape Shape "Rectangle 65,5,40,40,10 | FillColor 255,0,0,255 | StrokeWidth 0"][!SetVariable Switch "0"][!Redraw]
Sorry eclectic-tech, you beat me (again).
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Shape meter - Change color with !SetOption bang?

Post by jsmorley »

CrazyFrog wrote:Hello,

can someone tell me if it is possible to change color of Shape meter (Fill Color & Stroke Color) with Bangs?
You can, but keep in mind that Fill Color is not the "option" in the meter. It is just a parameter of the Shape option in that meter.

So you have two choices. You can replace the entire Shape option in that meter using !SetOption, or if it is a long complicated shape like a Path with tons of segments, it might be simpler to use a #Variable# for the particular bit you want to change, in this case the Fill Color

Code: Select all

[Rainmeter]
Update=1000
SkinWidth=110
SkinHeight=50
BackgroundMode=2
SolidColor=100,100,100

[Variables]
Switch=0
ShapeFill=255,255,255,255

[Measure_String]
Measure=String
String=#Switch#
DynamicVariables=1
IfCondition=(Measure_String = 0)
IfTrueAction=[!SetOption Meter_Roundline LineColor 0,255,0,255][!SetVariable ShapeFill "0,255,0,255"][!SetVariable Switch "1"][!Redraw]
IfCondition2=(Measure_String = 1)
IfTrueAction2=[!SetOption Meter_Roundline LineColor 255,0,0,255][!SetVariable ShapeFill "255,0,0,255]"[!SetVariable Switch "0"][!Redraw]

[Meter_Roundline]
Meter=Roundline
StartAngle=(Rad(0))
LineStart=0
LineLength=20
LineColor=255,255,255,255
Solid=1
AntiAlias=1
X=25
Y=25

[Meter_Shape]
Meter=Shape
Shape=Rectangle 65,5,40,40,10 | Fill Color #ShapeFill# | StrokeWidth 0
DynamicVariables=1
Edit: LOL both beat me...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Shape meter - Change color with !SetOption bang?

Post by eclectic-tech »

balala wrote: Sorry eclectic-tech, you beat me (again).
We both showed different ways to achieve the same result, so now the OP has options... :D
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Shape meter - Change color with !SetOption bang?

Post by balala »

eclectic-tech wrote:We both showed different ways to achieve the same result, so now the OP has options... :D
Yeah, right... :thumbup:
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Shape meter - Change color with !SetOption bang?

Post by jsmorley »

I think eclectic-tech's approach, using Extend to shorten and simply the bit you want to replace, and then use !SetOption, is probably the best overall... The !SetVariable approach is on the surface the most concise, but if you have a big skin with a lot of meters, you can end up having to create and deal with a blizzard of #Variables#.
CrazyFrog
Posts: 2
Joined: June 24th, 2017, 5:10 pm

Re: Shape meter - Change color with !SetOption bang?

Post by CrazyFrog »

Thank you all for help!
Post Reply