GE Lua Documentation

Press F to search!

rainbowColor

Definition


-- @/lua/common/utils.lua:49

function rainbowColor(numOfSteps, step, format)
  local x = step / max(numOfSteps, 1e-10)
  local r, g, b = min(1, max(0, 4 * x - 2)), min(1, max(0, 2 - abs(4 * x - 2))), min(1, max(0, 2 - 4 * x))
  if (format or 255) == 255 then
    return {floor(r*255), floor(g*255), floor(b*255), 255}
  else
    return {r, g, b, 1}
  end
end

Callers

@/lua/ge/extensions/editor/aiViz.lua
  if not drivabilityColorCache[data.drivability] then
    local rainbow = rainbowColor(50, clamp(data.drivability,0,1)*15, 1)
    drivabilityColorCache[data.drivability] = ColorF(rainbow[1], rainbow[2], rainbow[3],0.5)
  if not speedLimitCache[data.speedLimit] then
    local rainbow = rainbowColor(50, clamp(data.speedLimit, 0, 36), 1)
    local clr = ColorF(rainbow[1], rainbow[2], rainbow[3],0.5)
@/lua/ge/extensions/gameplay/race/path.lua
  for i, e in ipairs(self.aiDetailedPath) do
    local clr = rainbowColor(#self.aiDetailedPath, i, 1)
    debugDrawer:drawSphere(vec3(e.pos), 1, ColorF(clr[1], clr[2], clr[3], 0.6))
@/lua/ge/extensions/editor/vehicleEditor/liveEditor/veJBeamPicker.lua
local nodeDataRendering = {
  {name = "Displacement",     enabled = im.BoolPtr(false),    units = "m",      color = rainbowColor(8, 2, 1),   data = function(id) return vEditor.vehicle:getNodePosition(id):length() end, plotData = {}},
  {name = "Speed",            enabled = im.BoolPtr(true),     units = "m/s",    color = rainbowColor(8, 3, 1),   data = function(id) return vEditor.vehicle:getNodeVelocity(id):length() end, plotData = {}},
  {name = "Displacement",     enabled = im.BoolPtr(false),    units = "m",      color = rainbowColor(8, 2, 1),   data = function(id) return vEditor.vehicle:getNodePosition(id):length() end, plotData = {}},
  {name = "Speed",            enabled = im.BoolPtr(true),     units = "m/s",    color = rainbowColor(8, 3, 1),   data = function(id) return vEditor.vehicle:getNodeVelocity(id):length() end, plotData = {}},
  {name = "Relative Speed",   enabled = im.BoolPtr(false),    units = "m/s",    color = rainbowColor(8, 4, 1),   data = function(id) return (vEditor.vehicle:getVelocity() - vEditor.vehicle:getNodeVelocity(id)):length() end, plotData = {}},
  {name = "Speed",            enabled = im.BoolPtr(true),     units = "m/s",    color = rainbowColor(8, 3, 1),   data = function(id) return vEditor.vehicle:getNodeVelocity(id):length() end, plotData = {}},
  {name = "Relative Speed",   enabled = im.BoolPtr(false),    units = "m/s",    color = rainbowColor(8, 4, 1),   data = function(id) return (vEditor.vehicle:getVelocity() - vEditor.vehicle:getNodeVelocity(id)):length() end, plotData = {}},
  {name = "Force",            enabled = im.BoolPtr(false),    units = "N",      color = rainbowColor(8, 5, 1),   data = function(id) getVELuaNodeData(id, "force", "obj:getNodeForceVector(" .. id .. "):length()") return M.nodeDataFromVELua[id].force end, plotData = {}}
  {name = "Relative Speed",   enabled = im.BoolPtr(false),    units = "m/s",    color = rainbowColor(8, 4, 1),   data = function(id) return (vEditor.vehicle:getVelocity() - vEditor.vehicle:getNodeVelocity(id)):length() end, plotData = {}},
  {name = "Force",            enabled = im.BoolPtr(false),    units = "N",      color = rainbowColor(8, 5, 1),   data = function(id) getVELuaNodeData(id, "force", "obj:getNodeForceVector(" .. id .. "):length()") return M.nodeDataFromVELua[id].force end, plotData = {}}
}
local beamDataRendering = {
  {name = "Length",           enabled = im.BoolPtr(true),     units = "m",      color = rainbowColor(8, 2, 1),   data = function(id) return getBeamLength(id) end, plotData = {}},
  {name = "Speed",            enabled = im.BoolPtr(false),    units = "m/s",    color = rainbowColor(8, 3, 1),   data = function(id) getVELuaBeamData(id, "speed", "obj:getBeamVelocity(" .. id .. ")") return M.beamDataFromVELua[id].speed end, plotData = {}},
  {name = "Length",           enabled = im.BoolPtr(true),     units = "m",      color = rainbowColor(8, 2, 1),   data = function(id) return getBeamLength(id) end, plotData = {}},
  {name = "Speed",            enabled = im.BoolPtr(false),    units = "m/s",    color = rainbowColor(8, 3, 1),   data = function(id) getVELuaBeamData(id, "speed", "obj:getBeamVelocity(" .. id .. ")") return M.beamDataFromVELua[id].speed end, plotData = {}},
  {name = "Force",            enabled = im.BoolPtr(false),    units = "N",      color = rainbowColor(8, 4, 1),   data = function(id) getVELuaBeamData(id, "force", "obj:getBeamForce(" .. id .. ")") return M.beamDataFromVELua[id].force end, plotData = {}},
  {name = "Speed",            enabled = im.BoolPtr(false),    units = "m/s",    color = rainbowColor(8, 3, 1),   data = function(id) getVELuaBeamData(id, "speed", "obj:getBeamVelocity(" .. id .. ")") return M.beamDataFromVELua[id].speed end, plotData = {}},
  {name = "Force",            enabled = im.BoolPtr(false),    units = "N",      color = rainbowColor(8, 4, 1),   data = function(id) getVELuaBeamData(id, "force", "obj:getBeamForce(" .. id .. ")") return M.beamDataFromVELua[id].force end, plotData = {}},
  {name = "Stress",           enabled = im.BoolPtr(false),    units = "N",      color = rainbowColor(8, 5, 1),   data = function(id) getVELuaBeamData(id, "stress", "(select(1,obj:getBeamStressDamp(" .. id .. ")))") return M.beamDataFromVELua[id].stress end, plotData = {}},
  {name = "Force",            enabled = im.BoolPtr(false),    units = "N",      color = rainbowColor(8, 4, 1),   data = function(id) getVELuaBeamData(id, "force", "obj:getBeamForce(" .. id .. ")") return M.beamDataFromVELua[id].force end, plotData = {}},
  {name = "Stress",           enabled = im.BoolPtr(false),    units = "N",      color = rainbowColor(8, 5, 1),   data = function(id) getVELuaBeamData(id, "stress", "(select(1,obj:getBeamStressDamp(" .. id .. ")))") return M.beamDataFromVELua[id].stress end, plotData = {}},
  {name = "Damping",          enabled = im.BoolPtr(false),    units = "N",      color = rainbowColor(8, 6, 1),   data = function(id) getVELuaBeamData(id, "damping", "(select(2,obj:getBeamStressDamp(" .. id .. ")))") return M.beamDataFromVELua[id].damping end, plotData = {}},
  {name = "Stress",           enabled = im.BoolPtr(false),    units = "N",      color = rainbowColor(8, 5, 1),   data = function(id) getVELuaBeamData(id, "stress", "(select(1,obj:getBeamStressDamp(" .. id .. ")))") return M.beamDataFromVELua[id].stress end, plotData = {}},
  {name = "Damping",          enabled = im.BoolPtr(false),    units = "N",      color = rainbowColor(8, 6, 1),   data = function(id) getVELuaBeamData(id, "damping", "(select(2,obj:getBeamStressDamp(" .. id .. ")))") return M.beamDataFromVELua[id].damping end, plotData = {}},
}
@/lua/ge/extensions/gameplay/race/pathnode.lua

  clr = clr or rainbowColor(#self.path.pathnodes.sorted, (self.sortOrder-1), 1)
  if drawMode == 'highlight' then clr = {1,1,1,1} end
@/lua/ge/extensions/editor/objectToSplineEditor.lua
    for i, v in ipairs(savedPoints) do
      local c = rainbowColor(count, i, 1)
      debugDrawer:drawSphere(v.pos, 0.5, ColorF(c[1], c[2], c[3], 0.6))
@/lua/ge/extensions/editor/aiTests.lua
  for i, point in ipairs(route.path) do
    local clr = rainbowColor(#route.path, i, 1)
    local pos = vec3(point.pos)
@/lua/ge/extensions/editor/scriptAIManager.lua
    for i = 0, objMax do
      local col = rainbowColor(objMax + 1, i + 1, 1)
      table.insert(vehColors, ColorF(col[1], col[2], col[3], 0.2))
@/lua/ge/extensions/gameplay/rally/tools/rallyToolbox.lua
  --     for i, point in ipairs(preRoutePoints) do
  --       local clr = rainbowColor(#preRoutePoints, i, 1)
  --     debugDrawer:drawSphere(point.pos, 1.2, ColorF(clr[1], clr[2], clr[3], 0.8))
@/lua/ge/extensions/gameplay/rally/driveline/drivelineRoute.lua
  for i, point in ipairs(routeToDraw.path) do
    clr = rainbowColor(#routeToDraw.path, i, 1)
    pos = vec3(point.pos)
@/lua/ge/extensions/editor/perfProfiler.lua
          if not file.clr then
            local clr = rainbowColor(5.5, (f-1)%5.5, 1)
            file.clr = im.TableToArrayFloat({clr[1], clr[2], clr[3], clr[4]})
@/lua/ge/extensions/flowgraph/basenode.lua
      for i = 1, 10 do
        local c = rainbowColor(10,11-i,1)
        im.PushStyleColor2(im.Col_Button, im.ImVec4(c[1],c[2],c[3],0.5))
        if clr then
          local c = rainbowColor(10,11-clr,1)
          comment.backgroundColor[0] = im.Float(0.125+c[1]*0.75)
@/lua/ge/extensions/util/groundModelDebug.lua
    local v = core_environment.groundModels[k]
    groundModels[k] = {data = v.cdata, isAlias = v.isAlias, parent = v.parent, aliases = {}, active = im.BoolPtr(true), color = im.ArrayFloatByTbl(rainbowColor(groundModelSize, i, 1))}
    groundModels[k].cdata = {}
@/gameplay/missionTypes/collection/customNodes/collectionMarkersNode.lua
      if type(clr) == 'number' then
        clr = rainbowColor(36,(0.05+(0.75*clr))*12, 1)
      end
      clr = clr - clr%(0.05)
      clrByNum[clr] = clrByNum[clr] or color(unpack(rainbowColor(36,(0.05+(0.75*clr))*12)))
    end
      clr = clr - clr%(0.05)
      clrByNum[clr] = clrByNum[clr] or color(unpack(rainbowColor(36,(0.05+(0.75*clr))*12)))
    end
@/lua/ge/extensions/flowgraph/nodes/scene/raceLineParking.lua

  --local clr = clr or rainbowColor(0, 0, 1)
@/lua/ge/extensions/flowgraph/nodes/scene/collectionMarker.lua
      if type(clr) == 'number' then
        clr = rainbowColor(36,(0.8-(0.75*clr))*12, 1)
      end
@/lua/ge/extensions/flowgraph/nodes/debug/drawGraph.lua
      table.insert(self.inputLabels, pin.name)
      local c = rainbowColor(self.data.count, i, 255)
      table.insert(self.inputColors, im.ImColorByRGB(c[1], c[2], c[3], 255))
@/lua/ge/extensions/editor/util/plotHelperUtil.lua
    else
      local color = rainbowColor(rowCount, r, 1)
      splineColor = im.GetColorU322(im.ImVec4(color[1], color[2], color[3], color[4]))
    else
      local color = rainbowColor(count, r, 1)
      circleColor = im.GetColorU322(im.ImVec4(color[1], color[2], color[3], color[4]))
@/lua/ge/extensions/gameplay/race/pacenote.lua

  clr = clr or rainbowColor(#self.path.pacenotes.sorted, (self.sortOrder-1), 1)
  if drawMode == 'highlight' then clr = {1,1,1,1} end
@/lua/ge/extensions/gameplay/race/segment.lua
  if drawMode == 'none' then return end
  local clr = rainbowColor(#self.path.segments.sorted, (self.sortOrder-1), 1)
  if drawMode == 'highlight' then clr = {1,1,1,1} end
@/lua/ge/extensions/gameplay/race/startPosition.lua
  if drawMode == 'none' then return end
  clr = clr or rainbowColor(#self.race.startPositions.sorted, (self.sortOrder-1), 1)
  if drawMode == 'highlight' then clr = {1,1,1,1} end
@/lua/ge/map.lua
        else
          local rainbow = rainbowColor(50, clamp(edgeData.drivability, 0, 1) * 15, 1)
          edgeColor = ColorF(rainbow[1], rainbow[2], rainbow[3], 0.5)
      else
        local rainbow = rainbowColor(50, clamp(edgeData.drivability, 0, 1) * 15, 1)
        edgeColor = ColorF(rainbow[1], rainbow[2], rainbow[3], 0.5)