It is currently April 27th, 2024, 3:37 am

fading trough 3 colors... how to do it?

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: fading trough 3 colors... how to do it?

Post by balala »

Yincognito wrote: August 7th, 2020, 6:35 pm Yeah, the idea was to eliminate all the hardcoded values from the code (like 3 as the number of colors, 100 as the upper limit of your "Range" variable, etc.)
In meantime I also wrote (modified) a code to achive something similar. But in my code the number of colors is limited: it can be up to 10. I didn't work with the Range variable: it still goes from 0 to 100. To be honest I don't see clearly the advantage of the possibility to can set it to vary between other values.
In my code you don't have to manually specify the number of colors (so no need for the IdMax or some similar variable), the skin automatically determines the number of added colors. For now the not used colors have to have their components set to -1, but complicating a little bit the code, I think it is possible to can leave empty the components of the not needed / added colors (but this requires further measures).
Take care about the SolidColor option of the [MeterColor] meter, which is quite complicated. It probably doesn't tell nothing to most users.
Please let me know your opinion if you gave it a try:

Code: Select all

[Rainmeter]
Update=1000

[Variables]

R1=198
G1=251
B1=200
R2=196
G2=92
B2=38
R3=14
G3=175
B3=67
R4=19
G4=196
B4=118
R5=58
G5=95
B5=5
R6=-1
G6=-1
B6=-1
R7=-1
G7=-1
B7=-1
R8=-1
G8=-1
B8=-1
R9=-1
G9=-1
B9=-1
R10=-1
G10=-1
B10=-1

Range=0

[MeasureColor3]
Measure=String
String=#R3##G3##B3#
IfMatch=-1-1-1
IfMatchAction=[!SetVariable Color3 "0"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color3 "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1

[MeasureColor4]
Measure=String
String=#R4##G4##B4#
IfMatch=-1-1-1
IfMatchAction=[!SetVariable Color4 "0"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color4 "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1

[MeasureColor5]
Measure=String
String=#R5##G5##B5#
IfMatch=-1-1-1
IfMatchAction=[!SetVariable Color5 "0"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color5 "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1

[MeasureColor6]
Measure=String
String=#R6##G6##B6#
IfMatch=-1-1-1
IfMatchAction=[!SetVariable Color6 "0"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color6 "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1

[MeasureColor7]
Measure=String
String=#R7##G7##B7#
IfMatch=-1-1-1
IfMatchAction=[!SetVariable Color7 "0"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color7 "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1

[MeasureColor8]
Measure=String
String=#R8##G8##B8#
IfMatch=-1-1-1
IfMatchAction=[!SetVariable Color8 "0"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color8 "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1

[MeasureColor9]
Measure=String
String=#R9##G9##B9#
IfMatch=-1-1-1
IfMatchAction=[!SetVariable Color9 "0"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color9 "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1

[MeasureColor10]
Measure=String
String=#R10##G10##B10#
IfMatch=-1-1-1
IfMatchAction=[!SetVariable Color10 "0"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color10 "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1

[MeasureNumOfColors]
Measure=Calc
Formula=( 2 + #Color3# + #Color4# + #Color5# + #Color6# + #Color7# + #Color8# + #Color9# + #Color10# )
DynamicVariables=1
UpdateDivider=-1

[MeterColor]
Meter=Image
SolidColor=(((#Range#<=(100/([MeasureNumOfColors]-1)))*(#R1#+(#Range#/(100/([MeasureNumOfColors]-1)))*(#R2#-#R1#)))+(((#Range#>(100/([MeasureNumOfColors]-1)))&&(#Range#<=(200/([MeasureNumOfColors]-1))))*(#R2#+((#Range#-(100/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R3#-#R2#)))+(((#Range#>(200/([MeasureNumOfColors]-1)))&&(#Range#<=(300/([MeasureNumOfColors]-1))))*(#R3#+((#Range#-(200/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R4#-#R3#)))+(((#Range#>(300/([MeasureNumOfColors]-1)))&&(#Range#<=(400/([MeasureNumOfColors]-1))))*(#R4#+((#Range#-(300/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R5#-#R4#)))+(((#Range#>(400/([MeasureNumOfColors]-1)))&&(#Range#<=(500/([MeasureNumOfColors]-1))))*(#R5#+((#Range#-(400/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R6#-#R5#)))+(((#Range#>(500/([MeasureNumOfColors]-1)))&&(#Range#<=(600/([MeasureNumOfColors]-1))))*(#R6#+((#Range#-(500/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R7#-#R6#)))+(((#Range#>(600/([MeasureNumOfColors]-1)))&&(#Range#<=(700/([MeasureNumOfColors]-1))))*(#R7#+((#Range#-(600/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R8#-#R7#)))+(((#Range#>(700/([MeasureNumOfColors]-1)))&&(#Range#<=(800/([MeasureNumOfColors]-1))))*(#R8#+((#Range#-(700/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R9#-#R8#)))+(((#Range#>(800/([MeasureNumOfColors]-1)))&&(#Range#<=(900/([MeasureNumOfColors]-1))))*(#R9#+((#Range#-(800/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R10#-#R9#)))),(((#Range#<=(100/([MeasureNumOfColors]-1)))*(#G1#+(#Range#/(100/([MeasureNumOfColors]-1)))*(#G2#-#G1#)))+(((#Range#>(100/([MeasureNumOfColors]-1)))&&(#Range#<=(200/([MeasureNumOfColors]-1))))*(#G2#+((#Range#-(100/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G3#-#G2#)))+(((#Range#>(200/([MeasureNumOfColors]-1)))&&(#Range#<=(300/([MeasureNumOfColors]-1))))*(#G3#+((#Range#-(200/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G4#-#G3#)))+(((#Range#>(300/([MeasureNumOfColors]-1)))&&(#Range#<=(400/([MeasureNumOfColors]-1))))*(#G4#+((#Range#-(300/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G5#-#G4#)))+(((#Range#>(400/([MeasureNumOfColors]-1)))&&(#Range#<=(500/([MeasureNumOfColors]-1))))*(#G5#+((#Range#-(400/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G6#-#G5#)))+(((#Range#>(500/([MeasureNumOfColors]-1)))&&(#Range#<=(600/([MeasureNumOfColors]-1))))*(#G6#+((#Range#-(500/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G7#-#G6#)))+(((#Range#>(600/([MeasureNumOfColors]-1)))&&(#Range#<=(700/([MeasureNumOfColors]-1))))*(#G7#+((#Range#-(600/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G8#-#G7#)))+(((#Range#>(700/([MeasureNumOfColors]-1)))&&(#Range#<=(800/([MeasureNumOfColors]-1))))*(#G8#+((#Range#-(700/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G9#-#G8#)))+(((#Range#>(800/([MeasureNumOfColors]-1)))&&(#Range#<=(900/([MeasureNumOfColors]-1))))*(#G9#+((#Range#-(800/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G10#-#G9#)))),(((#Range#<=(100/([MeasureNumOfColors]-1)))*(#B1#+(#Range#/(100/([MeasureNumOfColors]-1)))*(#B2#-#B1#)))+(((#Range#>(100/([MeasureNumOfColors]-1)))&&(#Range#<=(200/([MeasureNumOfColors]-1))))*(#B2#+((#Range#-(100/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B3#-#B2#)))+(((#Range#>(200/([MeasureNumOfColors]-1)))&&(#Range#<=(300/([MeasureNumOfColors]-1))))*(#B3#+((#Range#-(200/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B4#-#B3#)))+(((#Range#>(300/([MeasureNumOfColors]-1)))&&(#Range#<=(400/([MeasureNumOfColors]-1))))*(#B4#+((#Range#-(300/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B5#-#B4#)))+(((#Range#>(400/([MeasureNumOfColors]-1)))&&(#Range#<=(500/([MeasureNumOfColors]-1))))*(#B5#+((#Range#-(400/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B6#-#B5#)))+(((#Range#>(500/([MeasureNumOfColors]-1)))&&(#Range#<=(600/([MeasureNumOfColors]-1))))*(#B6#+((#Range#-(500/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B7#-#B6#)))+(((#Range#>(600/([MeasureNumOfColors]-1)))&&(#Range#<=(700/([MeasureNumOfColors]-1))))*(#B7#+((#Range#-(600/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B8#-#B7#)))+(((#Range#>(700/([MeasureNumOfColors]-1)))&&(#Range#<=(800/([MeasureNumOfColors]-1))))*(#B8#+((#Range#-(700/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B9#-#B8#)))+(((#Range#>(800/([MeasureNumOfColors]-1)))&&(#Range#<=(900/([MeasureNumOfColors]-1))))*(#B9#+((#Range#-(800/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B10#-#B9#))))
X=0
Y=0
W=100
H=50
DynamicVariables=1
MouseScrollDownAction=[!SetVariable Range "(Clamp((#Range#-1),0,100))"][!UpdateMeter "#CURRENTSECTION#"][!UpdateMeter "Uptime"][!Redraw]
MouseScrollUpAction=[!SetVariable Range "(Clamp((#Range#+1),0,100))"][!UpdateMeter "#CURRENTSECTION#"][!UpdateMeter "Uptime"][!Redraw]
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: fading trough 3 colors... how to do it?

Post by Yincognito »

balala wrote: August 7th, 2020, 7:38 pmIn meantime I also wrote (modified) a code to achive something similar.
Nice! Well done! :thumbup:
balala wrote: August 7th, 2020, 7:38 pmI didn't work with the Range variable: it still goes from 0 to 100. To be honest I don't see clearly the advantage of the possibility to can set it to vary between other values.
The advantage is that you can slow down or fasten up the transition, by increasing or decreasing the Range interval, in my code. But I guess this can be done by means of update rate or changing the value that you add or subtract from Range in yours, so not a problem.
balala wrote: August 7th, 2020, 7:38 pmIn my code you don't have to manually specify the number of colors (so no need for the IdMax or some similar variable), the skin automatically determines the number of added colors.
Now that's nice indeed! Why didn't I think about that, I wonder?! :???: Anyway, I can't wait to see how you did it. ;-)
balala wrote: August 7th, 2020, 7:38 pmTake care about the SolidColor option of the [MeterColor] meter, which is quite complicated. It probably doesn't tell nothing to most users. Please let me know your opinion if you gave it a try:
Hm... I think I know what you did there. :D A bit longer, but I'm not afraid of it, I will analyze it properly. I'll give it a try for sure, that I can tell you, and will let you know what I think about your approach - either tonight or tomorrow. Either way, I can tell you by now: kudos to you for taking the challenge, and for your work on it. :great:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: fading trough 3 colors... how to do it?

Post by balala »

Yincognito wrote: August 7th, 2020, 8:04 pm Nice! Well done! :thumbup:
Thanks. I'm glad if you really think it is so. The code definitely requires improvements, but it does work for now.
Yincognito wrote: August 7th, 2020, 8:04 pm The advantage is that you can slow down or fasten up the transition, by increasing or decreasing the Range interval, in my code. But I guess this can be done by means of update rate or changing the value that you add or subtract from Range in yours, so not a problem.
Changing the added / substracted value is the easiest way, in my opinion.
Yincognito wrote: August 7th, 2020, 8:04 pm Now that's nice indeed! Why didn't I think about that, I wonder?!
No one can think to everything. That's one of the reasons why we're a great community here: one think to a detail which other didn't think to.
Yincognito wrote: August 7th, 2020, 8:04 pm Anyway, I can't wait to see how you did it. ;-)
Through the [MeasureColor3] - [MeasureColor10] String measures. I supposed the first two colors for sure are added, since the entire code doesn't make too much sense for less colors than two. All others are checked.
Yincognito wrote: August 7th, 2020, 8:04 pm Hm... I think I know what you did there. :D A bit longer, but I'm not afraid of it, I will analyze it properly. I'll give it a try for sure, that I can tell you, and will let you know what I think about your approach - either tonight or tomorrow.
Ok, please do so. I'm curious about your opinion...
Yincognito wrote: August 7th, 2020, 8:04 pm Either way, I can tell you by now: kudos to you for taking the challenge, and for your work on it. :great:
Thank you. Means a lot...
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: fading trough 3 colors... how to do it?

Post by Yincognito »

dvo wrote: August 7th, 2020, 7:42 pm looks nice :P it does it in steps ... by me ... :welcome: why don't u use the color picker from way back ... :D
LOL, which thing happens in steps, dvo? Cause if you talk about the transition, I don't know about your system, but on mine both my code and balala's deliver the transition smoothly, even with our other skins/programs loaded. If you talk about the preview GIF I posted, the frame rate is reduced compared to what happens in the original captured movie or in the skins, especially after the GIF optimization needed to reduce its size so I can attach it here. The only thing I can think of that could "work in steps" is on manual scrolling, and that's just because one cannot continuously scroll the mouse wheel by design, unless in programs supporting that feature to scroll pages, i.e. MS Word and such.

What color picker you're referring to, by the way? :D I'm sure there have been other attempts to create color transitions here on the forum (for sure jsmorley can link to a Lua implementation, for example), but then it's something else when you do it yourself and don't wonder over the hundreds of pages on the forum until you find what you're looking for (if you do, that is). Some might even be better, obviously.

Or... are you up for the challenge yourself and this is your way of telling it? :sly: Come on, don't be shy and step into the arena... let us throw colors at each other till only one color survives! 8-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: fading trough 3 colors... how to do it?

Post by jsmorley »

https://forum.rainmeter.net/viewtopic.php?f=27&t=26884#p140450

;-)


Yeah, I prefer Lua for that, since I find it much easier to deal with colors in HSB rather than RGB.
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: fading trough 3 colors... how to do it?

Post by brax64 »

I'm really amused, thank you all guys for your team work :thumbup:
Being part of this community it almost seems to own a software house :D got a problem? just ask! I love it!
Again thank you all for this awesome job you've done, I couldn't ever done by myself... :rosegift:
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: fading trough 3 colors... how to do it?

Post by Yincognito »

dvo wrote: August 7th, 2020, 8:44 pm all transitions are going the same way i'm already used to it... your anim shows smooth if i load it the script it goes in steps don't know why maybe 7
skins is to mutch lol rainmeter sucking up 22% cpu if i close it it goes to 2 just search on color picker ColorPickerPlus 1.1.0 ofrainguard is a new one i use a older one but jsMorley made colorpicker 4.3 and so on... how many pickers do you need? :17group :17group here are your dragon Z ballz O.O
here a bonus RainRGB4.exe again jsMorley :Whistle
Ah, yes - I figured out that was the problem you were alluding to, as we talked about it. Not sure what to say though, since for the vast majority of users things like these work just fine. By the way, I did NOT use Shape meters in my code, and I recall you saying you had no issues with Image meters ... so maybe that's an indication that you should look someplace else to find the culprit on your system. :???:

Regarding ColorPicker, well, these skins and ColorPicker do different things. It's about colors in both, but one thing is to pick a color and paste it in your skin and another thing is to make something in your skin fade between some colors on the fly. It's apples and oranges, really.
jsmorley wrote: August 7th, 2020, 8:57 pm https://forum.rainmeter.net/viewtopic.php?f=27&t=26884#p140450

;-)


Yeah, I prefer Lua for that, since I find it much easier to deal with colors in HSB rather than RGB.
Yep, Lua is another way to do it for sure. ;-) Regarding HSB, HSV and such, I admit I never tried to understand their usefulness. I'm most likely missing something as I'm not a color expert / scientist, but to me, as long as one has the RGB at his disposal, the HSV-like thing is a bit redundant (if we talk about creating colors, and not about other color components - for which they do indeed seem useful, so that I'm clear). You say you find it easier to deal with colors in HSB, but unless it's a plain linear "equation" to make such transitions, I feel a bit uncomfortable to convert to HSV/HSB, make the calculation, then convert back into RGB so I can display it using the Rainmeter code (if that's the process, that is - at least that's how I remember it to be reading about it on other sites)... :confused:

P.S. I guess one issue in understand the HSV / HSB thing is wrapping my head around the hue concept. Saturation and brightness, those I get it, but the hue thing ... I didn't quite grasp and probably never been really interested in doing it in the first place. :oops:
Last edited by Yincognito on August 7th, 2020, 9:47 pm, edited 1 time in total.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: fading trough 3 colors... how to do it?

Post by Yincognito »

brax64 wrote: August 7th, 2020, 9:33 pm I'm really amused, thank you all guys for your team work :thumbup:
Being part of this community it almost seems to own a software house :D got a problem? just ask! I love it!
Again thank you all for this awesome job you've done, I couldn't ever done by myself... :rosegift:
Aha!! So you finally got out of the rabbit hole, didn't you? :lol:
Good thing you're amused though, as that generally involves a good feeling, happiness and such. :great:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: fading trough 3 colors... how to do it?

Post by brax64 »

Food for thought...
Just because this conversation is so fascinating, I've found a skin that does an interesting manipulation of colors, it use lua though so I just superficially grasp how it works...
This skin is made by HipHopium at DA, the lua code is made by, try to guess..., jsmorley! :great:

https://1drv.ms/u/s!AqHC35yPJbKOgYJ1BwRp3uwXW77I_A?e=cAjySd
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: fading trough 3 colors... how to do it?

Post by Yincognito »

balala wrote: August 7th, 2020, 8:34 pmOk, please do so. I'm curious about your opinion...
Ok, so I looked over your code and I found "validating" the colors and the associated formulas in the SolidColor quite ingenious - very nicely done. I would probably be a bit concerned about the length of the option as it makes it harder to understand for most folks like you said, but I understand why it was necessary in your implementation.

I will probably have to think whether or not automatically detecting the number of colors can be done another way in my code, but then, in the end, one has to write those "color stops" RGB values anyway in order for the transition to work, so the question of whether one solves the number of colors topic using a variable (IdMax in my case) or through some validation technique involving measures doesn't really help in avoiding having to manually add the colors themselves in the first place. In any case, both methods are valid and work properly, that's for sure.

One more thing, since we're at it and we're sharing opinions: while your code indeed doesn't need modifications when adding or removing less than 11 colors, it does need adding to the formula in the SolidColor option if the number of colors goes beyond 10. That's not to say that it's wrong or anything like that, but my initial aim was to "make and forget" the code / skin, so that whenever I want a different number of colors to transition through I'd only have to input the "color stops" and "hit play", so to speak.

All in all, a great alternative to have. I liked the validation and the formula most and how they implicitly set the number of color automatically. A bit unfortunate that the length of the whole thing got bigger as a result, but then, someone else might very well find similar "quirks" in my code as well, if they're being picky, LOL. The imprtant thing is that it works flawlessly and that's all your credit, of course. :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth