GE Lua Documentation

Press F to search!

RGBtoHSV

Definition


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

--MARK: color things

function RGBtoHSV(r, g, b)
  local cMax = max(r,g,b)
  local cDelta = cMax - min(r,g,b)

  local h
  if r == cMax then h = (g-b)/(cDelta + 1e-10) % 6
  elseif g == cMax then h = 2 + (b-r)/(cDelta + 1e-10)
  else h = 4 + (r-g)/(cDelta + 1e-10)
  end

  return h / 6, cDelta/(cMax + 1e-10), cMax
end

Callers

@/lua/ge/extensions/freeroam/bigMapMode.lua
    local lineWidth = (camHeightAboveTerrain * camData.res.fov) / 20000
    local h, s, v = RGBtoHSV(unpack(core_groundMarkers.color)) -- groundMarkerColor
    local r, g, b = HSVtoRGB(h, s, 1)
    local lineWidth = (camHeightAboveTerrain * camData.res.fov) / 20000
    local h, s, v = RGBtoHSV(unpack(core_groundMarkers.color or {0.1, 0.25, 0.5})) -- groundMarkerColor
    local r, g, b = HSVtoRGB(h, 0.3, 1) -- routePreviewCol
@/lua/vehicle/partCondition.lua
  -- b) decrease overall saturation
  local h, s, v = RGBtoHSV(agedColor[1], agedColor[2], agedColor[3])
  s = s * saturationCoef