It is currently April 19th, 2024, 9:31 am

Colour chading?

Discuss the use of Lua in Script measures.
Ragingwasabi
Posts: 86
Joined: March 7th, 2015, 2:23 pm

Colour chading?

Post by Ragingwasabi »

Hi,
Im trying to use the Colourchanger script
http://rainmeter.net/forum/viewtopic.php?f=99&t=11135
in a meter where a square glows with brightness directly proportional to a measure's changing values.

Im trying to make it green, so I only want it as different shades of green, from a light green down to black for the lowest value. how would I set up this part to achieve that?

Colors=1,1,1,255|100,255,190,255

Right now it seems to be showing blue on low values instead and black for high values.
Switching the colours somewhow makes white show on low values. blue on high. this is very beffudling lol.
You do not have the required permissions to view the files attached to this post.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Colour chading?

Post by eclectic-tech »

You might want to check out this color blending method by Hakshak

I have used it, and it has a few more options... :thumbup:
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Colour chading?

Post by jsmorley »

I'm not entirely sure what is wrong with the math, but your measure:

Code: Select all

[PerRangeAlphaCalc]
measure=calc
;percentage=((value-min)/range), min=4000B, max=500000
formula=(([DriveAccess:2] - 4000) / 496000)
updatedivider=1
dynamicvariables=1
Is almost always returning a "negative" percentage, at least on my system. That is causing an error in the Lua, as you really can't have a negative percentage, and the skin is just sending out a blizzard of errors to the log on the Average() function.

If I change the measure to ensure it returns a positive percentage from 1-100:

Code: Select all

[PerRangeAlphaCalc]
measure=calc
Formula=(PerRangeAlphaCalc % 100) + 1
updatedivider=1
dynamicvariables=1
Then it seems to work fine, and cycles through:

Colors=1,1,1|100,255,190

as expected with no errors.

So I would re-examine your formula that is generating the "percentage", and see if there isn't some logic error in it. You can watch the values it is creating in the Manage / Skin panel. It really needs to return a positive percentage value from 0 to 100.

I have found that getting a "percentage" for disk read/write from PerfMon is tricky at best. It's hard to know what a valid "range" is for the values it returns.

Couple of other notes.

1) I have not looked closely, but I don't think you want to include the "alpha" component in the color code. Colors= should probably just be Colors=RRR,GGG,BBB|RRR,GGG,BBB

2) You have a couple of places you are using a Bar meter to create a static square or rectangle. Don't do that, it creates an error in the log, as Bar wants to have a measure bound to it. It works, since the value range used is 0 which is 100% of 0, but it spits out an error on every refresh. Just use Meter=Image with W/H/SolidColor to create static squares or rectangles.

Note: That script referenced by eclectic-tech does seem pretty promising... A few more options, a bit easier to follow, and not full of deprecated Lua / Rainmeter syntax. Smurfier's script is pretty old, and uses some syntax for integrating the Lua with the skin that while working, should really be changed.
Ragingwasabi
Posts: 86
Joined: March 7th, 2015, 2:23 pm

Re: Colour shading?

Post by Ragingwasabi »

@eclectic-tech thanks for that tip! Ill definitely use the new and easier one, i had no idea the colour changing script is outdated :/


@jsmorley ouch, i had no idea about that last point about the static bar errors. Ive been using that in all my skins -___-
For the negative errors it must be producing negatives when the measure is less than the minimum value of 4000 that i used to try set a range. Some how i totally forgot the fact that negatives exist.. Lol. Anyway this script does look very promising so far! I can see its gonna cut out the calculations part. thanks for the help once again :)
Ragingwasabi
Posts: 86
Joined: March 7th, 2015, 2:23 pm

Re: Colour changing?

Post by Ragingwasabi »

Aha I got it working! ^^ that script made it so easy :p
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Colour chading?

Post by eclectic-tech »

Glad to hear... :thumbup: