|
|
|
05-16-2018, 02:27 PM
|
#1
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Lua: Setting Item color
Hello scripters,
I've been trying to get and set item colors. But nothing I'm doing is working. I'm not getting script errors... just no change of color.
I've been using these commands:
To get item color value (this seems to be working fine):
Code:
Color_Val = reaper.GetMediaItemInfo_Value(Item, "I_CUSTOMCOLOR" )
And to impose a color value (this seems to not be working for me):
Code:
reaper.SetMediaItemTakeInfo_Value( Take, "I_CUSTOMCOLOR",88888888.0 )
No matter what I do, I can't re-color an item. Any help on what I'm missing?
Here is my test script:
Code:
function Msg (param)
reaper.ShowConsoleMsg(tostring (param).."\n")
end
function Main()
reaper.ClearConsole()
Num_of_Items = reaper.CountSelectedMediaItems(0)
Msg("Number of items: ".. Num_of_Items)
ii = 0
Note_Num = 0
for i = 0, Num_of_Items - 1 do
Item = reaper.GetSelectedMediaItem(0,i)
Take = reaper.GetMediaItemTake(Item, 0)
Item_Track = reaper.GetMediaItemTrack(Item)
_, Track_Name = reaper.GetTrackName(Item_Track, "")
_, Take_Name = reaper.GetSetMediaItemTakeInfo_String(Take, "P_NAME", Track_Name.. "Soft_".. Note_Num.. "_rr_".. i % 8 + 1 ,1)
if i >= Num_of_Items - 20 then
Color_Val = reaper.GetMediaItemInfo_Value(Item, "I_CUSTOMCOLOR" )
ii = ii + 1
Msg(ii.. ": ".. "Item: ".. i..", ".. Take_Name.. " color: ".. Color_Val)
end
reaper.SetMediaItemTakeInfo_Value( Take, "I_CUSTOMCOLOR",12345678 )
end
end
Main()
Cheers,
Andrew K
Last edited by Thonex; 05-16-2018 at 02:43 PM.
|
|
|
05-16-2018, 03:16 PM
|
#2
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Sorry, I'm in a rush:
- Color values are OS dependant; use the helper function.
- You have to bitwise OR with 0x1000000 (the API doc says 0x100000, but it's wrong)
- Try setting the item color, rather than the take.
Code:
reaper.SetMediaItemInfo_Value( Item, "I_CUSTOMCOLOR",reaper.ColorToNative(255,255,0)|0x1000000 )
Last edited by Lokasenna; 05-16-2018 at 03:48 PM.
|
|
|
05-16-2018, 03:44 PM
|
#3
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by Lokasenna
Sorry, I'm in a rush:
- Color values are OS dependant; use the helper function.
- You have to bitwise OR with 0x1000000
- Try setting the item color, rather than the take.
Code:
reaper.SetMediaItemInfo_Value( Item, "I_CUSTOMCOLOR",reaper.ColorToNative(255,255,0)|0x1000000 )
|
Thanks so much Lokasenna... and even being in a rush.. you are very helpful!
Will look at it now.
Cheers,
Andrew K
|
|
|
05-16-2018, 03:58 PM
|
#4
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Fantastic!!!
I had no idea about the OS dependent angle. I think I read somewhere that if you put a value of 0 it will not be black, but rater the default color.
Anyway... I need to read up some more... now that I know where to look. Thanks again. Very helpful and nondestructive.
Cheers,
Andrew K
|
|
|
05-17-2018, 05:03 AM
|
#5
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Yeah, the color-management in Reaper is real confusing if you're not familiar with it.
The only thing that's "normal" is using 0 for the default-color.
You can use ColorToNative()to get proper system-dependant color-values, though.
https://www.reaper.fm/sdk/reascript/...#ColorToNative
The returned color-values should(tm) work.
|
|
|
05-17-2018, 03:56 PM
|
#6
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by mespotine
Yeah, the color-management in Reaper is real confusing if you're not familiar with it.
The only thing that's "normal" is using 0 for the default-color.
You can use ColorToNative()to get proper system-dependant color-values, though.
https://www.reaper.fm/sdk/reascript/...#ColorToNative
The returned color-values should(tm) work.
|
Thanks for the additional info mespotine!
Thankfully I'm not going after Pantone (tm) accuracy
Cheers,
Andrew K
|
|
|
11-06-2019, 07:56 PM
|
#7
|
Human being with feelings
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,619
|
Quote:
Originally Posted by Lokasenna
- You have to bitwise OR with 0x1000000 (the API doc says 0x100000, but it's wrong)
|
Thanks for this, Lokasenna.
Docs are *still* wrong.
|
|
|
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 03:57 AM.
|