It is currently June 25th, 2019, 6:28 am

Change Color (Gradient) based on value

Help with creating, editing & fixing problems with skins
Carje
Posts: 6
Joined: March 22nd, 2019, 4:23 pm

Change Color (Gradient) based on value

Carje » March 22nd, 2019, 4:54 pm

I am trying to change the percentage value colors of CPU and RAM from the default SYSTEM skin, based on their value, with a gradient
(ie: CPU - from green to orange to red - 0%-50%-90% / RAM - 0)

I searched on the forum and google also but I only found how to change only one color, and failed to make it worked. Some of the codes were too old and don't work anymore and others I simply didn't managed to make them work.

Thanks in advance!
User avatar
balala
Rainmeter Sage
Posts: 8308
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Color (Gradient) based on value

balala » March 22nd, 2019, 5:00 pm

Carje wrote:
March 22nd, 2019, 4:54 pm
I am trying to change the percentage value colors of CPU and RAM from the default SYSTEM skin,
Let's take it step by step. First are you talking about the System skin of illustro package?
Carje
Posts: 6
Joined: March 22nd, 2019, 4:23 pm

Re: Change Color (Gradient) based on value

Carje » March 22nd, 2019, 6:31 pm

balala wrote:
March 22nd, 2019, 5:00 pm
Let's take it step by step. First are you talking about the System skin of illustro package?
Yes. I don't think this is so important since the code should be the same everywhere, only the implementation may differ
User avatar
balala
Rainmeter Sage
Posts: 8308
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Color (Gradient) based on value

balala » March 22nd, 2019, 6:33 pm

Carje wrote:
March 22nd, 2019, 6:31 pm
Yes. I don't think this is so important since the code should be the same everywhere, only the implementation may differ
Ok. What do you mean by
Carje wrote:
March 22nd, 2019, 4:54 pm
the percentage value colors of CPU and RAM
and what by
Carje wrote:
March 22nd, 2019, 4:54 pm
with a gradient
?
Carje
Posts: 6
Joined: March 22nd, 2019, 4:23 pm

Re: Change Color (Gradient) based on value

Carje » March 22nd, 2019, 7:03 pm

The text itself (9%,13%,67%,etc)

As I said in the topic : (ie: CPU - from green to orange to red - 0%-50%-90% / RAM - 0) - 9% 18% 24% 33% 41% 52% 63% 70% 79% 84% 90%

As the number get's higher the color turns more red
As the number get's lower the color turns more green
With orange being the middle color
User avatar
balala
Rainmeter Sage
Posts: 8308
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Color (Gradient) based on value

balala » March 22nd, 2019, 7:09 pm

Carje wrote:
March 22nd, 2019, 7:03 pm
The text itself (9%,13%,67%,etc)

As I said in the topic : (ie: CPU - from green to orange to red - 0%-50%-90% / RAM - 0) - 9% 18% 24% 33% 41% 52% 63% 70% 79% 84% 90%

As the number get's higher the color turns more red
As the number get's lower the color turns more green
With orange being the middle color
Still not very clear to me, but let's see. Do you want the color of the number showing the percentage to change continuously, accordingly to the CPU usage? So the string always should have to have one, continuously changing color.
Have I understood this correctly?
Carje
Posts: 6
Joined: March 22nd, 2019, 4:23 pm

Re: Change Color (Gradient) based on value

Carje » March 22nd, 2019, 7:20 pm

balala wrote:
March 22nd, 2019, 7:09 pm
Still not very clear to me, but let's see. Do you want the color of the number showing the percentage to change continuously, accordingly to the CPU usage? So the string always should have to have one, continuously changing color.
Have I understood this correctly?
Basically yes. I don't know if there is anything that can change colors in a gradient automatically or I need to make myself "if's" for every other percent to make it more real. But that's the point, updating the color at the same time with CPU usage
User avatar
balala
Rainmeter Sage
Posts: 8308
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Color (Gradient) based on value

balala » March 22nd, 2019, 7:25 pm

Carje wrote:
March 22nd, 2019, 7:20 pm
Basically yes. I don't know if there is anything that can change colors in a gradient automatically or I need to make myself "if's" for every other percent to make it more real. But that's the point, updating the color at the same time with CPU usage
Ok. Let me a half of hour to look deeper into how to do this. I'll come back a bit later with an answer.
User avatar
balala
Rainmeter Sage
Posts: 8308
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change Color (Gradient) based on value

balala » March 22nd, 2019, 8:04 pm

Try to add the following FontColor option to the [meterValueCPU] meter: FontColor=(Clamp((5.1*[MeasureCPU]),0,255)),(Clamp((255-(2.55*[MeasureCPU])),0,255)),0. Along with this FontColor, you have to add as well a DynamicVariables=1 option to the same [meterValueCPU] meter. Don't forget nor this.
Carje
Posts: 6
Joined: March 22nd, 2019, 4:23 pm

Re: Change Color (Gradient) based on value

Carje » March 22nd, 2019, 8:47 pm

balala wrote:
March 22nd, 2019, 8:04 pm
Try to add the following FontColor option to the [meterValueCPU] meter: FontColor=(Clamp((5.1*[MeasureCPU]),0,255)),(Clamp((255-(2.55*[MeasureCPU])),0,255)),0. Along with this FontColor, you have to add as well a DynamicVariables=1 option to the same [meterValueCPU] meter. Don't forget nor this.
Perfect, it worked!

So, to understand the code:
R = Clamp((5.1*[MeasureCPU]),0,255) -> R is 5.1 * MeasureCPU value with a value of min 0 and max 255
G = Clamp((255-(2.55*[MeasureCPU])),0,255) -> G is 2.55 * MeasureCPU value, subtracted from 255, with a value of min 0 and max 255
B = 0
MeasureCPU value being an integer of CPU usage between 0 and 100

Is this right ?