finding the closest web safe color if I have a palette
snippet in lua

finding the closest web safe color if I have a palette

user535

local max_color_component_value = 255
local quantum = max_color_component_value / 5

r = quantum * math.floor((r + (quantum / 2)) / quantum)
g = quantum * math.floor((g + (quantum / 2)) / quantum)
b = quantum * math.floor((b + (quantum / 2)) / quantum)