It is currently November 29th, 2021, 5:23 am

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

Help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 4101
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 9th, 2020, 7:39 pm Alright. I don't contest anyone's (your) code is better then mine. :thumbup:
I didn't say that. I only said it's shorter, since you appeared to be uncomfortable with the code becoming longer. All codes that work as expected are equally good, from a functional point of view, IMHO.
User avatar
balala
Rainmeter Sage
Posts: 13497
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 9th, 2020, 7:47 pm I didn't say that. I only said it's shorter, since you appeared to be uncomfortable with the code becoming longer. All codes that work as expected are equally good, from a functional point of view, IMHO.
Agree here!
dvo wrote: August 9th, 2020, 8:16 pm i always and still enjoy the code of balala
It definitely is simpler, but much - much longer then Yincognito's code. Question is who, which one does prefer...
User avatar
Yincognito
Rainmeter Sage
Posts: 4101
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

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

Post by Yincognito »

Exactly, folks. :thumbup: Which is why I'll share (hopefully) the final version of my "upgraded" / "updated" / whatever you want to call it Color Wheel, which integrates the stringification of setting up the R,G,B,A type of variables as well:

Code: Select all

[Variables]
; Color Array (set it to a "<ColorNumber>:<Red>,<Green>,<Blue>,<Alpha>;" enumeration)
Colors="0:255,0,0,255;1:255,0,255,255;2:0,0,255,255;3:0,255,255,255;4:0,255,0,255;5:255,255,0,255;6:255,0,0,255;"
; Maximum Value (decrease to speed up the transition, decrease to slow it down)
Range=384
; Value's Step (decrease to slow down the transition, increase to speed it up; negative values to transition backwards)
VStep=1

[Rainmeter]
Update=25
DynamicWindowSize=1
AccurateText=1

---Measures---

[SetRGBA]
Measure=String
String=#Colors#
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?U)(.+):(.+),(.+),(.+),(.+);":"[!SetVariable R\1 \2][!SetVariable G\1 \3][!SetVariable B\1 \4][!SetVariable A\1 \5]","(\d+)(\s+\S+\])$":"\1\2[!SetVariable IdMax \1]","(?U)^(\[.+\s+(\S+)\]\[.+\s+(\S+)\]\[.+\s+(\S+)\]\[.+\s+(\S+)\])":"[!SetVariable R \2][!SetVariable G \3][!SetVariable B \4][!SetVariable A \5]\1"
OnUpdateAction=[SetRGBA]

[Value]
Group=ColorGroup
Disabled=1
Measure=Calc
Formula=((#Range#+Value+#VStep#)%#Range#)
OnUpdateAction=[!SetVariable Interval (([#Range]+1)/[#IdMax])][!SetVariable SIndex (Trunc([Value]/(([#Range]+1)/[#IdMax])))][!SetVariable EIndex (Trunc([Value]/(([#Range]+1)/[#IdMax]))+1)]
DynamicVariables=1

[Color]
Group=ColorGroup
Disabled=1
Measure=Calc
OnUpdateAction=[!SetVariable R ([#R[#SIndex]]+(([Value]-[#SIndex]*[#Interval])/[#Interval])*([#R[#EIndex]]-[#R[#SIndex]]))][!SetVariable G ([#G[#SIndex]]+(([Value]-[#SIndex]*[#Interval])/[#Interval])*([#G[#EIndex]]-[#G[#SIndex]]))][!SetVariable B ([#B[#SIndex]]+(([Value]-[#SIndex]*[#Interval])/[#Interval])*([#B[#EIndex]]-[#B[#SIndex]]))][!SetVariable A "255"][!UpdateMeter "Shape"][!Redraw]
RegExpSubstitute=1
Substitute="^.*$":"#R#,#G#,#B#,#A#","\.\d+":"","(\d+)":"  \1","[ \d]*([ \d]{3})":"\1"," ":"  "
DynamicVariables=1

---Meters---

[Shape]
Meter=Shape
Shape=Rectangle 0,0,200,100,12 | StrokeWidth 0 | Stroke Color 255,255,255,255 | Fill Color #R#,#G#,#B#,#A#
MouseScrollDownAction=[!SetVariable VStep -1][!EnableMeasureGroup ColorGroup][!UnpauseMeasureGroup ColorGroup][!UpdateMeasureGroup ColorGroup][!PauseMeasureGroup ColorGroup][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseScrollUpAction=[!SetVariable VStep 1][!EnableMeasureGroup ColorGroup][!UnpauseMeasureGroup ColorGroup][!UpdateMeasureGroup ColorGroup][!PauseMeasureGroup ColorGroup][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
LeftMouseUpAction=[!UnpauseMeasureGroup ColorGroup][!ToggleMeasureGroup ColorGroup][!SetVariable R #R0#][!SetVariable G #G0#][!SetVariable B #B0#][!SetVariable A #A0#][!UpdateMeasureGroup ColorGroup][!UpdateMeter #CURRENTSECTION#][!Redraw]
MiddleMouseUpAction=[!TogglePauseMeasureGroup ColorGroup]
DynamicVariables=1

[Text]
Meter=STRING
X=([Shape:W]/2)r
Y=([Shape:H]/2)r
W=([Shape:W])
H=([Shape:H])
FontFace=Tahoma
FontColor=255,255,255,255
FontSize=10
FontWeight=700
AntiAlias=1
StringAlign=CenterCenter
StringEffect=Shadow
FontEffectColor=0,0,0,255
Text="TRANSITION: Color Wheel#CRLF#DIRECTION: #VStep##CRLF#COLOR: [Color]#CRLF#TRANSITION UPDATES: #Range#"
DynamicVariables=1
As you can see, I made my own code shorter using that technique too. Now I'm finally happy with the result. :D
User avatar
balala
Rainmeter Sage
Posts: 13497
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 9th, 2020, 8:41 pm Exactly, folks. :thumbup: Which is why I'll share (hopefully) the final version of my "upgraded" / "updated" / whatever you want to call it Color Wheel, which integrates the stringification of setting up the R,G,B,A type of variables as well:
Yes, but why are you using the Update set to Update=25? It's too low, doesn't worth, even Update=-1 does work, the only thing you have to add is a [!UpdateMeter "Text"] bang to the MouseScrollDownAction and MouseScrollUpAction options of the [Shape] meter.
User avatar
Yincognito
Rainmeter Sage
Posts: 4101
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 9th, 2020, 8:47 pm Yes, but why are you using the Update set to Update=25? It's too low, doesn't worth, even Update=-1 does work, the only thing you have to add is a [!UpdateMeter "Text"] bang to the MouseScrollDownAction and MouseScrollUpAction options of the [Shape] meter.
Yeah, but I wanted not only to be able to transition on scroll, but also by triggering it on left click, pausing it by middle clicking and so on. In other words:
- scrolling does the transition manually, either forwards or backwards
- the 1st left click stops it and resets it to the first color, the 2nd left click runs it automatically (this is where a fast update rate is handy)
- middle click pauses it
Unless I'm missing something, one wouldn't be able to run the transition automatically if the update rate is negative. And if it's set to 1000 ms, it would take ages to complete.