View Single Post
Old 06-16-2019, 04:12 PM   #505
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,968
Default

I was playing with HSV colors for another script, so I quickly scribbled this random track color generator that only generates strong colors:

Code:
function hsv2rgb(h, s, v, a)
    local i = (h * 6)//1
    local f = h * 6 - i
    local p = v * (1 - s)
    local q = v * (1 - f * s)
    local t = v * (1 - (1 - f) * s)

    local r, g, b
      
    i = i % 6
    if i == 0 then r, g, b = v, t, p
    elseif i == 1 then r, g, b = q, v, p
    elseif i == 2 then r, g, b = p, v, t
    elseif i == 3 then r, g, b = p, q, v
    elseif i == 4 then r, g, b = t, p, v
    elseif i == 5 then r, g, b = v, p, q
    end
  
    return r * 255, g * 255, b * 255, a * 255
end

math.randomseed (os.time ())
for i = 0, reaper.CountSelectedTracks(0)-1 do
    tr = reaper.GetSelectedTrack(0, i)
    hue = math.random()
    r, g, b = hsv2rgb(hue, 1, 1, 1)
    color = 0x01000000 | ((r//1)<<16) | ((g//1)<<8) | (b//1)
    reaper.SetTrackColor(tr, color)
end
juliansader is online now   Reply With Quote