|
|
|
05-03-2017, 01:00 PM
|
#1
|
Human being with feelings
Join Date: Feb 2016
Location: Colorado Springs, CO
Posts: 25
|
SWS Auto Color - Gradient Children
Is it possible to have children tracks auto gradient based off the parent's color? When I set children to gradient it sets anything that is a child (regardless of parent) to a gradient starting with black.
I have rules for my various Master folders to set them to different colors and was hoping to have the children to be set to gradients of that color. Is that possible?
|
|
|
12-08-2019, 09:16 AM
|
#2
|
Human being with feelings
Join Date: Dec 2014
Posts: 597
|
UP! (yeah, from the abbyss I know...)
|
|
|
12-09-2019, 05:20 AM
|
#3
|
Human being with feelings
Join Date: Apr 2016
Posts: 653
|
I'd like to know this as well.
|
|
|
12-10-2019, 08:47 PM
|
#4
|
Human being with feelings
Join Date: Aug 2019
Posts: 853
|
Bump. I expect this is probably already possible, this thread just hasn't been seen by one of the eight people who understand how to do it yet
What would be good is if you can assign your parent to a custom colour, and then the child tracks gradient FROM that parent custom colour to your next custom colour only. As long as your custom colours are organised in a logical order this should always look nice and tidy.
Hopefully someone will spot this and help us out.
|
|
|
12-11-2019, 05:12 AM
|
#5
|
Human being with feelings
Join Date: Dec 2014
Posts: 597
|
Yes, that would be very cool and handy for non-coding people :-D
|
|
|
12-11-2019, 07:01 AM
|
#6
|
Human being with feelings
Join Date: Sep 2019
Location: Finland
Posts: 755
|
Quote:
Originally Posted by bassburner
Is it possible to have children tracks auto gradient based off the parent's color? When I set children to gradient it sets anything that is a child (regardless of parent) to a gradient starting with black.
|
I was literally just today fiddling with my auto-colour settings and wondering why I couldn't find an option to do this.
__________________
Artist name Ben Enkindle. Making electronic music exclusively with Linux software.
Last edited by elcalen; 12-11-2019 at 07:03 AM.
Reason: Clarify what I was referring to
|
|
|
04-05-2020, 09:23 PM
|
#7
|
Human being with feelings
Join Date: Sep 2008
Location: Adelaide, Australia
Posts: 159
|
Nice idea!
Would like to see if this could be achieved also!
|
|
|
12-15-2020, 05:30 AM
|
#8
|
Human being with feelings
Join Date: Feb 2018
Posts: 19
|
Great idea, anyone find a way to do this?
I did find that you have some great gradient customization with Heda's track inspector, but that doesn't have the convenience of SWS auto color. So when you add new tracks, it doesn't update their color automatically.
|
|
|
01-05-2021, 12:22 PM
|
#9
|
Human being with feelings
Join Date: Nov 2018
Posts: 155
|
Did anybody figure this out? I am looking for a solution to this also!
|
|
|
01-09-2021, 06:00 AM
|
#10
|
Human being with feelings
Join Date: Nov 2020
Posts: 138
|
oh that would be cool!
|
|
|
01-10-2021, 10:40 AM
|
#11
|
Human being with feelings
Join Date: Nov 2018
Posts: 155
|
Anyone? Anyone?
|
|
|
01-10-2021, 11:19 AM
|
#12
|
Human being with feelings
Join Date: Apr 2020
Posts: 214
|
I've made something like this for myself. It's not automatic, but it works fine for me. I run it as a component of custom actions for different circumstances.
It only changes the colors of tracks you've selected and it simply offsets the current color values, making them darker. Children of children etc. are progressively darker, while top level folders are unchanged.
It's here: https://pastebin.com/Lze5JL3L
What is perhaps also useful are these two scripts for just offsetting the color values of the selected tracks, making them progressively brighter or darker: https://pastebin.com/aw0781ca and https://pastebin.com/wEARfX8u
Hope that can work for you.
|
|
|
01-10-2021, 07:48 PM
|
#13
|
Human being with feelings
Join Date: Nov 2018
Posts: 155
|
This looks just like what I am looking for. Thank you so much for sharing!
|
|
|
01-18-2021, 06:08 AM
|
#14
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Quote:
Originally Posted by poulhoi
I've made something like this for myself. It's not automatic, but it works fine for me. I run it as a component of custom actions for different circumstances.
It only changes the colors of tracks you've selected and it simply offsets the current color values, making them darker. Children of children etc. are progressively darker, while top level folders are unchanged.
It's here: https://pastebin.com/Lze5JL3L
What is perhaps also useful are these two scripts for just offsetting the color values of the selected tracks, making them progressively brighter or darker: https://pastebin.com/aw0781ca and https://pastebin.com/wEARfX8u
Hope that can work for you.
|
Great Paul!
I was looking for something like that, i started from your script
and modified in a way that you select 1 folder parent and it automatically gradients children tracks, based on the folder track color.
SWS actions needed to make my coding quick.
doesn't work with multiple folders selections for now, but I think I can do it.
Code:
local selchildren = reaper.NamedCommandLookup("_SWS_SELCHILDREN")
local colchildren = reaper.NamedCommandLookup("_SWS_COLCHILDREN")
local gradientstep = -15
function main()
reaper.Main_OnCommandEx(colchildren, 0, 0)
reaper.Main_OnCommandEx(selchildren, 0, 0)
local trackCount = reaper.CountSelectedTracks(0)
for i = 0, trackCount - 2, 1 do
local track = reaper.GetSelectedTrack(0, i)
local nexttrack = reaper.GetSelectedTrack(0, i+1)
local prevColorNative = reaper.GetTrackColor(track)
local prevColorR, prevColorG, prevColorB = reaper.ColorFromNative(prevColorNative)
if prevColorR + gradientstep < 0 then prevColorR = 0 else prevColorR = prevColorR + gradientstep end
if prevColorG + gradientstep < 0 then prevColorG = 0 else prevColorG = prevColorG + gradientstep end
if prevColorB + gradientstep < 0 then prevColorB = 0 else prevColorB = prevColorB + gradientstep end
local newColorR = math.min(prevColorR, 255)
local newColorG = math.min(prevColorG, 255)
local newColorB = math.min(prevColorB, 255)
local newColorNative = reaper.ColorToNative(newColorR, newColorG, newColorB)
reaper.SetTrackColor(nexttrack, newColorNative)
end
end
reaper.Undo_BeginBlock()
reaper.PreventUIRefresh(1)
main()
reaper.Main_OnCommandEx(40297, 0, 0)
reaper.PreventUIRefresh(-1)
reaper.Undo_EndBlock( "folder Gradient", 0)
|
|
|
01-18-2021, 10:42 AM
|
#15
|
Human being with feelings
Join Date: Dec 2014
Posts: 597
|
@80icio : your script works quite well but is there a way to define the gradientStep relatively to the number of children ?
|
|
|
01-18-2021, 01:30 PM
|
#16
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Quote:
Originally Posted by daeavelwyn
@80icio : your script works quite well but is there a way to define the gradientStep relatively to the number of children ?
|
there it is!
the more tracks, the more the color steps get smaller .
Code:
local selchildren = reaper.NamedCommandLookup("_SWS_SELCHILDREN")
local colchildren = reaper.NamedCommandLookup("_SWS_COLCHILDREN")
local itemtotrkcolor = reaper.NamedCommandLookup("_SWS_ITEMTRKCOL")
---Gradient Step ---- positive numbers will gradient to white // negative numbers will gradient to black
local gradientstep = -15 ---- 0 = no gradient
local coloritem = true -----if true = force to color items in tracks
function main()
reaper.Main_OnCommandEx(colchildren, 0, 0)
reaper.Main_OnCommandEx(selchildren, 0, 0)
local trackCount = reaper.CountSelectedTracks(0)
local gradientstep = math.ceil((gradientstep*10)/(trackCount+1)) ----dependent on track count
for i = 0, trackCount - 2, 1 do
local track = reaper.GetSelectedTrack(0, i)
local nexttrack = reaper.GetSelectedTrack(0, i+1)
local prevColorNative = reaper.GetTrackColor(track)
local prevColorR, prevColorG, prevColorB = reaper.ColorFromNative(prevColorNative)
if prevColorR + gradientstep < 0 then prevColorR = 0 else prevColorR = prevColorR + gradientstep end
if prevColorG + gradientstep < 0 then prevColorG = 0 else prevColorG = prevColorG + gradientstep end
if prevColorB + gradientstep < 0 then prevColorB = 0 else prevColorB = prevColorB + gradientstep end
local newColorR = math.min(prevColorR, 255)
local newColorG = math.min(prevColorG, 255)
local newColorB = math.min(prevColorB, 255)
local newColorNative = reaper.ColorToNative(newColorR, newColorG, newColorB)
reaper.SetTrackColor(nexttrack, newColorNative)
end
if coloritem == true then
reaper.Main_OnCommandEx(40718, 0, 0)
reaper.Main_OnCommandEx(itemtotrkcolor, 0, 0)
end
end
reaper.Undo_BeginBlock()
reaper.PreventUIRefresh(1)
main()
reaper.Main_OnCommandEx(40769, 0, 0)
reaper.PreventUIRefresh(-1)
reaper.Undo_EndBlock( "folder Gradient", 0)
|
|
|
01-18-2021, 01:47 PM
|
#17
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Script attached
|
|
|
01-18-2021, 02:07 PM
|
#18
|
Human being with feelings
Join Date: Dec 2014
Posts: 597
|
Yeah ! Very nice !
Another little behaviour I'd like to avoid, when the script finished, folder track is unselected, is there a way to keep track selected ?
|
|
|
01-18-2021, 03:42 PM
|
#19
|
Human being with feelings
Join Date: Jun 2018
Location: Edmonton, AB, Canada
Posts: 1,391
|
I downloaded the script and am using it too. Thanks 80icio!
__________________
My Rig (also serves as my gaming PC): MSI Mag X570 Tomahawk Mobo, Ryzen R9 3900X, 32GB RAM, Samsung 960 Evo 500gb NVMe, Crucial 1TB NVMe, NVidia RTX 2080 Super, Arturia Minifuse 2, Nektar Impact LX25+ MIDI Controller Keyboard.
|
|
|
01-18-2021, 04:55 PM
|
#20
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
edit: just found another bug... give me a minute!
|
|
|
01-18-2021, 05:06 PM
|
#21
|
Human being with feelings
Join Date: Dec 2014
Posts: 597
|
80icio, thanks a lot for your work ! Do you plan to release your work throught reapack ?
|
|
|
01-18-2021, 05:20 PM
|
#22
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
There it is
v1.2
- Multiple folder track selection
- selected tracks stay the same after the script
Depending on the Theme you use color gradient will be more noticeable,
You can open the script and modify the gradient step in case.
let me know if you encounter any bugs.
Happy rainbow mixing!
|
|
|
01-18-2021, 05:38 PM
|
#23
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Quote:
Originally Posted by daeavelwyn
80icio, thanks a lot for your work ! Do you plan to release your work throught reapack ?
|
you're welcome!
Honestly I use Reapack to download scripts, but I don't really know how the repository thing works....
If you just select all tracks with ctrl+A the script will automatically get folders and set children track colours
Last edited by 80icio; 01-18-2021 at 05:48 PM.
|
|
|
01-18-2021, 05:45 PM
|
#24
|
Human being with feelings
Join Date: Dec 2014
Posts: 597
|
Wow ! It's now working like a charm, thanks so much !
|
|
|
01-18-2021, 05:45 PM
|
#25
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by 80icio
Honestly I use Reapack to download scripts, but I don't really know how the repository thing works....
|
https://reapack.com/upload
|
|
|
01-18-2021, 05:56 PM
|
#26
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Quote:
Originally Posted by cfillion
|
Wow! Mr. ReaPack in person!
thanks for the hint!
Before uploading, I might add a function to check if SWS is installed
|
|
|
01-19-2021, 08:18 AM
|
#27
|
Human being with feelings
Join Date: Nov 2018
Posts: 155
|
This is fantastic! Thank you so much for creating this script. Exactly what I was looking for!
|
|
|
02-01-2021, 04:17 AM
|
#28
|
Human being with feelings
Join Date: Mar 2018
Posts: 72
|
Hey 80icio, great script. But if I want colors from normal to brighter what needs to be changed in the code for this?
|
|
|
02-05-2021, 12:17 AM
|
#29
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Quote:
Originally Posted by kovarny
Hey 80icio, great script. But if I want colors from normal to brighter what needs to be changed in the code for this?
|
Thanks!
Code:
local gradientstep = -15
this is the variable you have to change in the script
if number is positive it will color gradient the track towards white.
|
|
|
04-10-2021, 09:44 AM
|
#30
|
Human being with feelings
Join Date: Oct 2020
Posts: 6
|
Any way to prevent manually colored items from being changed?
I love this script! My only complaint is that it overrides any manual item color settings. I would prefer an option for it to re-color only the items that have not been manually set.
This behaviour seems to be how the command 40421 (Item: Select all items in track) is combined with itemtotrkcolor.
Code:
if coloritem == true then
r.Main_OnCommandEx(40421, 0, 0)
r.Main_OnCommandEx(itemtotrkcolor, 0, 0)
Built-in track coloring actions (EG. 40358 - Track: Set to random colors) re-color both the track, and only items of "default" color.
I'm not yet savvy enough to work out this feature for myself. Do you think it's possible to select items of default color instead of using 40421?
PS. another, likely way larger, feature request would be a way to set the gradient step in HSB independently.
Last edited by mendel; 04-10-2021 at 10:44 AM.
|
|
|
04-11-2021, 01:03 AM
|
#31
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Quote:
I'm not yet savvy enough to work out this feature for myself. Do you think it's possible to select items of default color instead of using 40421?
|
You got it already!
Get rid of that line and it'll work the way you're saying, the SWS command which colours items to track color doesn't override your coloring.
try it on a new session with default coloured tracks
If you don't want to cancel that line just put 2 minus signs before the line
Code:
if coloritem == true then
--r.Main_OnCommandEx(40421, 0, 0)
r.Main_OnCommandEx(itemtotrkcolor, 0, 0)
Quote:
PS. another, likely way larger, feature request would be a way to set the gradient step in HSB independently.
|
I had a quick look on Reaper's API but no trace of access to direct HSB variables. The only way would be to translate RGB values to Hue or Brightness or saturation.
The way the script is working right now adds RGB values the same way every step, so I guess it corresponds to Brightness , not sure if there's any math i can do to translate rgb steps to hue or saturation.
|
|
|
04-11-2021, 06:25 AM
|
#32
|
Human being with feelings
Join Date: Apr 2020
Posts: 214
|
Quote:
Originally Posted by 80icio
I had a quick look on Reaper's API but no trace of access to direct HSB variables. The only way would be to translate RGB values to Hue or Brightness or saturation.
The way the script is working right now adds RGB values the same way every step, so I guess it corresponds to Brightness , not sure if there's any math i can do to translate rgb steps to hue or saturation.
|
X-Raym put together some functions for this; they’re available on ReaPack. I made a new version of my original script using them and it works great.
|
|
|
04-11-2021, 08:20 AM
|
#33
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Quote:
Originally Posted by poulhoi
X-Raym put together some functions for this; they’re available on ReaPack. I made a new version of my original script using them and it works great.
|
Wow! thanks for sharing!
Having a look right now .
|
|
|
06-13-2021, 04:50 AM
|
#34
|
Human being with feelings
Join Date: Jun 2019
Posts: 21
|
Thank you!!
Quote:
Originally Posted by 80icio
There it is
v1.2
- Multiple folder track selection
- selected tracks stay the same after the script
Depending on the Theme you use color gradient will be more noticeable,
You can open the script and modify the gradient step in case.
let me know if you encounter any bugs.
Happy rainbow mixing!
|
Awesome Script- thank you!
Had a play with this just now and managed to add an offset by adding a second loop and also got it to work with Auto Colors and sub folders etc. so I thought other may find it useful if they stumble across this thread like I did today!
Thanks again,
G
P.S. I attached an image of the action and result in case it is of any use to anyone!
P.P.S.
Offset Loop:
Code:
--gd loop
for i = 0, trackCount - 1, 1 do
local track = r.GetSelectedTrack(0, i)
local ColorNative = r.GetTrackColor(track)
local ColorR, ColorG, ColorB = r.ColorFromNative(ColorNative)
if math.max(math.max(ColorR,ColorG),ColorB)+GDOFFSET<256 then
local newColorR = math.min(ColorR, 255)+GDOFFSET
local newColorG = math.min(ColorG, 255)+GDOFFSET
local newColorB = math.min(ColorB, 255)+GDOFFSET
local newColorNative = r.ColorToNative(newColorR, newColorG, newColorB)
r.SetTrackColor(track, newColorNative)
if coloritem == true then
r.Main_OnCommandEx(40421, 0, 0)
r.Main_OnCommandEx(itemtotrkcolor, 0, 0)
end
end
end
|
|
|
06-17-2021, 01:29 PM
|
#35
|
Human being with feelings
Join Date: May 2021
Posts: 2
|
Quote:
Originally Posted by GLD
Awesome Script- thank you!
Had a play with this just now and managed to add an offset by adding a second loop and also got it to work with Auto Colors and sub folders etc. so I thought other may find it useful if they stumble across this thread like I did today!
Thanks again,
G
P.S. I attached an image of the action and result in case it is of any use to anyone!
P.P.S.
Offset Loop:
Code:
--gd loop
for i = 0, trackCount - 1, 1 do
local track = r.GetSelectedTrack(0, i)
local ColorNative = r.GetTrackColor(track)
local ColorR, ColorG, ColorB = r.ColorFromNative(ColorNative)
if math.max(math.max(ColorR,ColorG),ColorB)+GDOFFSET<256 then
local newColorR = math.min(ColorR, 255)+GDOFFSET
local newColorG = math.min(ColorG, 255)+GDOFFSET
local newColorB = math.min(ColorB, 255)+GDOFFSET
local newColorNative = r.ColorToNative(newColorR, newColorG, newColorB)
r.SetTrackColor(track, newColorNative)
if coloritem == true then
r.Main_OnCommandEx(40421, 0, 0)
r.Main_OnCommandEx(itemtotrkcolor, 0, 0)
end
end
end
|
Hi GLD, could you share your updated script please? Thanks in advance
|
|
|
01-19-2022, 07:41 PM
|
#36
|
Human being with feelings
Join Date: Nov 2009
Location: Montreal, Canada
Posts: 9,048
|
Quote:
Originally Posted by poulhoi
I've made something like this for myself. It's not automatic, but it works fine for me. I run it as a component of custom actions for different circumstances.
It only changes the colors of tracks you've selected and it simply offsets the current color values, making them darker. Children of children etc. are progressively darker, while top level folders are unchanged.
It's here: https://pastebin.com/Lze5JL3L
What is perhaps also useful are these two scripts for just offsetting the color values of the selected tracks, making them progressively brighter or darker: https://pastebin.com/aw0781ca and https://pastebin.com/wEARfX8u
Hope that can work for you.
|
These are very cool, but they're not quite working well for me. I think it's not quite "getting" the current color properly. It seems to work well for subsequent presses, but that first one doesn't seem to start off from the right shade. It has also just gone and given me weird colors out of the blue, pardon the pun.
I was also wondering if it is possible to code it such that each jump in brightness or darkness is dependent on the color the track previously was. Meaning, rather than increasing by 30 each time, when it's black it might only increase by 10, and when it's more pale, it will increase by 50 or something. using a bit of a logarithmic formula or something like that.
Quote:
Originally Posted by 80icio
you're welcome!
Honestly I use Reapack to download scripts, but I don't really know how the repository thing works....
If you just select all tracks with ctrl+A the script will automatically get folders and set children track colours
|
How difficult would it be to make some thing sort of similar, except, what it does is it goes and changes all Folders, and subfolders to brighter and brighter colors. So, the folders are darker and the children are lighter, and same level folders will be same color, and same level children same color. This way, I get an idea what level I am, just by looking at the children.
Last edited by Sound asleep; 01-19-2022 at 07:52 PM.
|
|
|
02-14-2022, 11:15 AM
|
#37
|
Human being with feelings
Join Date: Nov 2009
Location: Montreal, Canada
Posts: 9,048
|
Quote:
Originally Posted by poulhoi
I've made something like this for myself. It's not automatic, but it works fine for me. I run it as a component of custom actions for different circumstances.
It only changes the colors of tracks you've selected and it simply offsets the current color values, making them darker. Children of children etc. are progressively darker, while top level folders are unchanged.
It's here: https://pastebin.com/Lze5JL3L
What is perhaps also useful are these two scripts for just offsetting the color values of the selected tracks, making them progressively brighter or darker: https://pastebin.com/aw0781ca and https://pastebin.com/wEARfX8u
Hope that can work for you.
|
I really like this, but I would like to make 2 changes to it, if possible. I don't mind finding the values and stuff myself, but I'm not sure how to go about it from a coding standpoint.
What I would like to do is to have a sliding scale by how much a given RGB value will change. For example, if R >240 it reduces by 50. Or, something like that, maybe just a simple fraction of the value would work as well. Like I said, I can figure out the values, as long as I know what's the code I would need to make it make relative changes like that.
The other change I would like to make, is that if the next reduction takes it past zero, it doesn't wrap around, it stays at zero, until all values are zero. So, if you pressed the darker button, it would always eventually become black and settle there. And the same thing for brighter, but the other way, maxing out at 255.
Is it possible to do this?
|
|
|
02-15-2022, 01:54 PM
|
#38
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Quote:
Originally Posted by Sound asleep
I really like this, but I would like to make 2 changes to it, if possible. I don't mind finding the values and stuff myself, but I'm not sure how to go about it from a coding standpoint.
What I would like to do is to have a sliding scale by how much a given RGB value will change. For example, if R >240 it reduces by 50. Or, something like that, maybe just a simple fraction of the value would work as well. Like I said, I can figure out the values, as long as I know what's the code I would need to make it make relative changes like that.
The other change I would like to make, is that if the next reduction takes it past zero, it doesn't wrap around, it stays at zero, until all values are zero. So, if you pressed the darker button, it would always eventually become black and settle there. And the same thing for brighter, but the other way, maxing out at 255.
Is it possible to do this?
|
That's already happening on my script
Code:
if prevColorR + gradientstep < 0 then prevColorR = 0 else prevColorR = prevColorR + gradientstep end
if prevColorG + gradientstep < 0 then prevColorG = 0 else prevColorG = prevColorG + gradientstep end
if prevColorB + gradientstep < 0 then prevColorB = 0 else prevColorB = prevColorB + gradientstep end
local newColorR = math.min(prevColorR, 255)
local newColorG = math.min(prevColorG, 255)
local newColorB = math.min(prevColorB, 255)
Here's where the gradient step gets proportional to the number of tracks involved
Code:
local gradientstep = math.ceil((gradientstep*10)/(trackCount+1)) ----dependent on track count
|
|
|
02-19-2022, 09:43 AM
|
#39
|
Human being with feelings
Join Date: Nov 2009
Location: Montreal, Canada
Posts: 9,048
|
Quote:
Originally Posted by 80icio
That's already happening on my script
Code:
if prevColorR + gradientstep < 0 then prevColorR = 0 else prevColorR = prevColorR + gradientstep end
if prevColorG + gradientstep < 0 then prevColorG = 0 else prevColorG = prevColorG + gradientstep end
if prevColorB + gradientstep < 0 then prevColorB = 0 else prevColorB = prevColorB + gradientstep end
local newColorR = math.min(prevColorR, 255)
local newColorG = math.min(prevColorG, 255)
local newColorB = math.min(prevColorB, 255)
Here's where the gradient step gets proportional to the number of tracks involved
Code:
local gradientstep = math.ceil((gradientstep*10)/(trackCount+1)) ----dependent on track count
|
I'm gonna see if I can work it out with that information, but as cool as the gradient steps are, I am more just trying to create a keystroke that just makes a track darker by some value, which is proportional to the value it just was. Meaning if the value is near 255, the step will be greater. Like if the step could be PrevcolorR*1/3 So, at 255 the step would be 85 and at 30, the step would be 10 for example. Idk the best fraction or whatever, but something like that.
Maybe I could tell it "local gradientstepR = PrevcolorR * 1/3 ?
and make 3 gradientsteps for RGB?
I'm gonna test this out in a minute.
EDIT: I tried my hand at it, but, for some reason it just always goes to black, no matter what value I put for the gradient. I tried to mix and match your scripts with my limited understanding.
Code:
local gradientstep = -2
local coloritem = true -----if true = force to color items/takes with track color
local trktbl = {}
function main()
local trackCount = reaper.CountSelectedTracks2(0, 1)
for i = 0, trackCount - 1, 1 do
local track = reaper.GetSelectedTrack(0, i)
local nexttrack = reaper.GetSelectedTrack(0, i+1)
local prevColorNative = reaper.GetTrackColor(track)
local prevColorR, prevColorG, prevColorB = reaper.ColorFromNative(prevColorNative)
if prevColorR + gradientstep < 0 then prevColorR = 0 else prevColorR = prevColorR + gradientstep end
if prevColorG + gradientstep < 0 then prevColorG = 0 else prevColorG = prevColorG + gradientstep end
if prevColorB + gradientstep < 0 then prevColorB = 0 else prevColorB = prevColorB + gradientstep end
local newColorR = math.min(prevColorR, 255)
local newColorG = math.min(prevColorG, 255)
local newColorB = math.min(prevColorB, 255)
local newColorNative = reaper.ColorToNative(newColorR, newColorG, newColorB)
reaper.SetTrackColor(track, newColorNative)
end
end
reaper.PreventUIRefresh(1)
main()
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()
I put -2 just to be sure, but it still went to black, which makes me feel like it believes the < 0 requirements were met. I was wondering also, if it would be possible to put "prevColorR * gradient step" rather than say "+ gradient step"
Last edited by Sound asleep; 02-19-2022 at 12:11 PM.
|
|
|
02-20-2022, 10:50 AM
|
#40
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
You can play around with the gradient step value, this code darken all the selected tracks color by that amount.
Making it proportional is possible (like R G B go down by 10% everytime you run the script)
But I think this script is simpler and makes the job
Code:
----------------ICIO - Darken Track Color-----------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
------------------------------------?:^) written by 80icio -----------------------------------------------
----------------------------------------------------------------------------------------------------------
--- v1.0
local r = reaper
local verifysws = reaper.APIExists( 'CF_GetSWSVersion' )------- my easy way to check if SWS extensions are installed
if verifysws then
local itemtotrkcolor = r.NamedCommandLookup("_SWS_ITEMTRKCOL")
---Gradient Step ---- positive numbers will gradient to white // negative numbers will gradient to black
local gradientstep = -30 ---- 0 = no gradient
local coloritem = true -----if true = force to color items/takes with track color
local trktbl = {}
function getseltracktable()
local trackCount = r.CountSelectedTracks(0)
if trackCount ~= 0 then
for i = 1, trackCount, 1 do
trktbl[i] = r.GetSelectedTrack(0, i-1)
end
end
end
function main()
local trackCount = r.CountSelectedTracks(0)
for i = 0, trackCount - 1, 1 do
local track = r.GetSelectedTrack(0, i)
local prevColorNative = r.GetTrackColor(track)
local prevColorR, prevColorG, prevColorB = r.ColorFromNative(prevColorNative)
if prevColorR + gradientstep < 0 then prevColorR = 0 else prevColorR = prevColorR + gradientstep end
if prevColorG + gradientstep < 0 then prevColorG = 0 else prevColorG = prevColorG + gradientstep end
if prevColorB + gradientstep < 0 then prevColorB = 0 else prevColorB = prevColorB + gradientstep end
local newColorR = math.min(prevColorR, 255)
local newColorG = math.min(prevColorG, 255)
local newColorB = math.min(prevColorB, 255)
local newColorNative = r.ColorToNative(newColorR, newColorG, newColorB)
r.SetTrackColor(track, newColorNative)
if coloritem == true then
r.Main_OnCommandEx(40421, 0, 0)
r.Main_OnCommandEx(itemtotrkcolor, 0, 0)
end
end
end
r.Undo_BeginBlock()
--r.PreventUIRefresh(1)
getseltracktable()
if #trktbl ~=0 then
main()
end
r.PreventUIRefresh(-1)
r.Undo_EndBlock( "Darken Track Color", 1)
else
reaper.ShowMessageBox( "SWS/S&M extensions not installed download from https://www.sws-extension.org/", "", 0 )
end
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:07 AM.
|