-- すべて[0,1]の範囲に正規化してください -- Hue(色相) [0,1] / Saturation(彩度) [0,1] / Value(明度) [0,1] function HSVtoRGB(h, s, v) local r = v local g = v local b = v if 0 < s then h = h * 6.0 local i = math.floor(h) local f = h - i if i == 0 then g = 1.0 - s * (1.0 - f) b = 1.0 - s end if i == 1 then r = 1.0 - s * f b = 1.0 - s end if i == 2 then r = 1.0 - s b = 1.0 - s * (1.0 - f) end if i == 3 then r = 1.0 - s g = 1.0 - s * f end if i == 4 then r = 1.0 - s * (1.0 - f) g = 1.0 - s end if i == 5 then g = 1.0 - s b = 1.0 - s * f end end return Color.__new(r, g, b) end