It is currently October 19th, 2021, 3:58 pm

Using variable with RGB in histogram's PrimaryColor?

Get help with installing and using Rainmeter.
Kannan
Posts: 6
Joined: August 26th, 2016, 5:31 am

Using variable with RGB in histogram's PrimaryColor?

Post by Kannan »

I have the following script measure in a include.ini file:

Code: Select all

[ColorFG1RGB]
Measure=Script
ScriptFile=#@#HEXToRGB.lua
Source=FG1
It has RGB values in the format of "255,0,0".
I have included the above ColorFG1RGB in my skin as below.

Code: Select all

[Variables]
Color1RGB=[ColorFG1RGB]
When I check in the "About Rainmeter" window I see the following
For "ColorFG1RGB"
Range: 0.0 - 1.0
Number: 255
String: 255,0,0
For Color1RGB
Range: (empty)
Number: (empty)
String: [ColorFG1RGB]
Now I have a histogram in my skin as follows

Code: Select all

[CPUTemp1Histogram]
Meter=Histogram
MeasureName=CPUTemp1Current
X=0R
Y=0R
W=210
H=60
PrimaryColor=#Color1RGB#
SolidColor=0,0,0,100
AntiAlias=1
I expected the histogram to be in red colour, instead, it's white.

Can someone please help me to identify the issue?
I believe the Color1RGB is picked up as a number instead of a string.
Last edited by Kannan on June 15th, 2021, 6:09 am, edited 1 time in total.
User avatar
death.crafter
Posts: 1045
Joined: April 24th, 2021, 8:13 pm

Re: Using variable with RGB in histogram's PrimaryColor?

Post by death.crafter »

Kannan wrote: June 11th, 2021, 7:56 am I have the following script measure in a include.ini file:

Code: Select all

[ColorFG1RGB]
Measure=Script
ScriptFile=#@#HEXToRGB.lua
Source=FG1
It has RGB values in the format of "255,0,0".
I have included the above ColorFG1RGB in my skin as below.

Code: Select all

[Variables]
Color1RGB=[ColorFG1RGB]
When I check in the "About Rainmeter" window I see the following




Now I have a histogram in my skin as follows

Code: Select all

[CPUTemp1Histogram]
Meter=Histogram
MeasureName=CPUTemp1Current
X=0R
Y=0R
W=210
H=60
PrimaryColor=#Color1RGB#
SolidColor=0,0,0,100
AntiAlias=1
Rather than using a variable you can use [&ColorFG1RGB] as the color.
If you are trying to use a variable for switching purposes you can directly !SetVariable or !WriteKeyValue using "[ColorFG1RGB]".
Kannan wrote: June 11th, 2021, 7:56 am I expected the histogram to be in red colour, instead, it's white.

Can someone please help me to identify the issue?
I believe the Color1RGB is picked up as a number instead of a string.
No. It is picked up as a string. But since "[ColorFG1RGB]" is not a color it defaults to white. At least that's what I think is happening.

P.S.: You can directly use hex values too(without the #), unless you want RGB for some very specific reason.
from the Realm of Death
My Current Desktop
Kannan
Posts: 6
Joined: August 26th, 2016, 5:31 am

Re: Using variable with RGB in histogram's PrimaryColor?

Post by Kannan »

Thank you for responding to the post.
death.crafter wrote: June 11th, 2021, 9:40 am
Rather than using a variable you can use [&ColorFG1RGB] as the color.
I tried using PrimaryColor=[ColorFG1RGB], this still results in white instead of red.
death.crafter wrote: June 11th, 2021, 9:40 am If you are trying to use a variable for switching purposes you can directly !SetVariable or !WriteKeyValue using "[ColorFG1RGB]".
The variable is already declared, do I still need to declare again using !SetVariable?

Code: Select all

[Variables]
Color1RGB=[ColorFG1RGB]
I also tried the PrimaryColor=[!WriteKeyValue "Color1RGB"] and that also doesn't work.

Code: Select all

[CPUTemp1Histogram]
Meter=Histogram
MeasureName=CPUTemp1Current
X=0R
Y=0R
W=210
H=60
PrimaryColor=[!WriteKeyValue "Color1RGB]
SolidColor=0,0,0,100
AntiAlias=1
death.crafter wrote: June 11th, 2021, 9:40 am No. It is picked up as a string. But since "[ColorFG1RGB]" is not a color it defaults to white. At least that's what I think is happening.
You are correct. As mentioned in my previous post, when I checked the about window, the variable [ColorFG1RGB] holds the RGB colour as a string, and 255 as a number.
death.crafter wrote: June 11th, 2021, 9:40 am P.S.: You can directly use hex values too(without the #), unless you want RGB for some very specific reason.
The hex values are actually generated by the Chameleon plugin, hence I can't set the value.
User avatar
death.crafter
Posts: 1045
Joined: April 24th, 2021, 8:13 pm

Re: Using variable with RGB in histogram's PrimaryColor?

Post by death.crafter »

Kannan wrote: June 11th, 2021, 10:02 am Thank you for responding to the post.


I tried using PrimaryColor=[ColorFG1RGB], this still results in white instead of red.


The variable is already declared, do I still need to declare again using !SetVariable?

Code: Select all

[Variables]
Color1RGB=[ColorFG1RGB]
I also tried the PrimaryColor=[!WriteKeyValue "Color1RGB"] and that also doesn't work.

Code: Select all

[CPUTemp1Histogram]
Meter=Histogram
MeasureName=CPUTemp1Current
X=0R
Y=0R
W=210
H=60
PrimaryColor=[!WriteKeyValue "Color1RGB]
SolidColor=0,0,0,100
AntiAlias=1

You are correct. As mentioned in my previous post, when I checked the about window, the variable [ColorFG1RGB] holds the RGB colour as a string, and 255 as a number.


The hex values are actually generated by the Chameleon plugin, hence I can't set the value.
I guess I should have been more specific. But without the full code here I can't understand what's going on.

And even if color is given by chameleon you can use it directly as PrimaryColor= [ChameleonChildMeasure]. (Replacing ChameleonChildMeasure with your measure name).

And [!WriteKeyValue "Color1RGB] is not a thing. See bangs section for more clarity.

But I am not sure why PrimaryColor=[ColorFG1RGB] wouldn't work. May be try [&ColorFG1RGB].

And please post the skin here as a zip or rmskin for us to know what is actually going on.

Thanks,
death.crafter
from the Realm of Death
My Current Desktop
Kannan
Posts: 6
Joined: August 26th, 2016, 5:31 am

Re: Using variable with RGB in histogram's PrimaryColor?

Post by Kannan »

death.crafter wrote: June 11th, 2021, 10:16 am But I am not sure why PrimaryColor=[ColorFG1RGB] wouldn't work. May be try [&ColorFG1RGB].
I tried PrimaryColor=[&ColorFG1RGB], this didn't work.
death.crafter wrote: June 11th, 2021, 10:16 am And please post the skin here as a zip or rmskin for us to know what is actually going on.
Currently, my skin is a mess, I will write a new simple skin and post it.
User avatar
SilverAzide
Rainmeter Sage
Posts: 1615
Joined: March 23rd, 2015, 5:26 pm

Re: Using variable with RGB in histogram's PrimaryColor?

Post by SilverAzide »

Kannan wrote: June 11th, 2021, 10:02 am
The [Variable] section should not be needed and might not even work depending on where in the file it is. The value of this variable is being set to the value of the [ColorFG1RGB] measure, and that measure might not have a value yet. Variables are resolved by Rainmeter very early in the process of loading your skin, so it is possible the measure is returning nothing.

As death.crafter pointed out, PrimaryColor=[!WriteKeyValue "Color1RGB] is gibberish, so you need to fix this line. As he mentioned, PrimaryColor=[ColorFG1RGB] should work, but make sure you add DynamicVariables=1 to the measure. I suspect that is the line you are missing.
Gadgets Wiki GitHub More Gadgets...
User avatar
balala
Rainmeter Sage
Posts: 13324
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using variable with RGB in histogram's PrimaryColor?

Post by balala »

Kannan wrote: June 11th, 2021, 7:56 am Can someone please help me to identify the issue?
A little bit late on the show, however here is my opinion on the arose questions.
First, unless I misunderstood the problem, I believe you'd like to set the value of the [ColorFG1RGB] measure to the Color1RGB variable. Since the [ColorFG1RGB] measure is a Script measure (which uses the HEXToRGB.lua script file, which is not given, we don't know it), giving the variable into the [Variables] section with the Color1RGB=[ColorFG1RGB] assignment, won't work, because the value of the variable is given probably before the HEXToRGB.lua script file returns a value (if it returns one - this depends on the not-known script) - see SilverAzide's reply above as well. There night be different approaches on how to assign the value to the variable, probably you should use either an OnChangeAction=[!SetVariable Color1RGB "[ColorFG1RGB]"] option on the [ColorFG1RGB] measure (but this is questionable if does work), or enter the option to set the value of the variable into the HEXToRGB.lua code itself (probably better approach). To can give an advice on how to do it, we probably will need the code of the HEXToRGB.lua file as well. Best would be you to pack the whole config and upload the package here (as also asked by death.crafter above, even if he asked just the code). This way we'd have all needed files and would be much easier to help.
Kannan
Posts: 6
Joined: August 26th, 2016, 5:31 am

Re: Using variable with RGB in histogram's PrimaryColor?

Post by Kannan »

Hello all,

Thank you for your inputs.
I have cleaned up the skin and kept a simple CPU meter along with variables names as string metres to help.

Since the attachment limit in this forum is 10 mb and mine is 15 mb, I uploaded it to a public temporary file sharing service.
The skin (HWiNFO Chameleon.zip) is available at https://file.io/JXenwVKfpQnZ.

Meanwhile, I tried the mentioned suggestions and none are working, not sure what mistake I'm making.

Please note that you will need the HWiNFO (https://www.hwinfo.com/download/) executable to be running, if not I request you to replace the CPU measure with a built-in one that Rainmeter provides.

The meter in question is MeterHWiNFOCPU0UsageHistogram and the variables are available in the section [Variables] in KannanHardwareInfoChameleonText.ini
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4428
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Using variable with RGB in histogram's PrimaryColor?

Post by eclectic-tech »

Kannan wrote: June 11th, 2021, 7:56 am I have the following script measure in a include.ini file:

Code: Select all

[ColorFG1RGB]
Measure=Script
ScriptFile=#@#HEXToRGB.lua
Source=FG1
It has RGB values in the format of "255,0,0".
I have included the above ColorFG1RGB in my skin as below.

Code: Select all

[Variables]
Color1RGB=[ColorFG1RGB]
When I check in the "About Rainmeter" window I see the following




Now I have a histogram in my skin as follows

Code: Select all

[CPUTemp1Histogram]
Meter=Histogram
MeasureName=CPUTemp1Current
X=0R
Y=0R
W=210
H=60
PrimaryColor=#Color1RGB#
SolidColor=0,0,0,100
AntiAlias=1
I expected the histogram to be in red colour, instead, it's white.

Can someone please help me to identify the issue?
I believe the Color1RGB is picked up as a number instead of a string.
Late to the party, but...

Why use "ScriptFile=#@#HEXToRGB.lua" when you can obtain either Hex or RGB values directly from the Chameleon plugin?
The default value returned by a Chameleon measure is a Hex formatted value, but by adding Format=Dec to the measure it will return a RGB formatted value.

Code: Select all

[ChameleonDesktop]
Measure=Plugin
Plugin=Chameleon
Type=Desktop

[DesktopFG1]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Color=Foreground1
Format=Dec
You can use that measure's RGB value in the histogram color.

Code: Select all

[CPUTemp1Histogram]
Meter=Histogram
MeasureName=CPUTemp1Current
X=0R
Y=0R
W=210
H=60
PrimaryColor=[DesktopFG1]
DynamicVariables=1
SolidColor=0,0,0,100
AntiAlias=1
BTW, the file posted by you has been deleted!?
User avatar
death.crafter
Posts: 1045
Joined: April 24th, 2021, 8:13 pm

Re: Using variable with RGB in histogram's PrimaryColor?

Post by death.crafter »

Kannan wrote: June 12th, 2021, 12:37 pm Hello all,

Thank you for your inputs.
I have cleaned up the skin and kept a simple CPU meter along with variables names as string metres to help.

Since the attachment limit in this forum is 10 mb and mine is 15 mb, I uploaded it to a public temporary file sharing service.
The skin (HWiNFO Chameleon.zip) is available at https://file.io/JXenwVKfpQnZ.

Meanwhile, I tried the mentioned suggestions and none are working, not sure what mistake I'm making.

Please note that you will need the HWiNFO (https://www.hwinfo.com/download/) executable to be running, if not I request you to replace the CPU measure with a built-in one that Rainmeter provides.

The meter in question is MeterHWiNFOCPU0UsageHistogram and the variables are available in the section [Variables] in KannanHardwareInfoChameleonText.ini
Works fine.
Screenshot 2021-06-12 190733.png
In circle variant ini, change @Include=#@#\ChameleonStyle.ini and @Include=#@#\HWiNFO.inc to @Include=#@#ChameleonStyle.ini and #@#HWiNFO.inc.

Because the @ variable comes with a backslash(\).

And in the meters you want to use Lua generated colors use DynamicVariables=1

For example:

Code: Select all

[MeterCPUCircle]
Meter=Roundline
MeasureName=HWiNFOCPU0UsageCurrent
X=0
Y=0
W=#CanvasSize#
H=#CanvasSize#
StartAngle=(Rad(270))
RotationAngle=(Rad(360))
LineStart=#CircleLineStart#
LineLength=#CircleLineLength#
Solid=1
LineColor=[DesktopFG1]

_________________________________
DynamicVariables=1
-----------------------------------------------
AntiAlias=1
You do not have the required permissions to view the files attached to this post.
from the Realm of Death
My Current Desktop