File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,40 +16,32 @@ local sRGB = {}
1616-- Equivalent to f_inv. Takes a linear sRGB channel and returns
1717-- the sRGB channel
1818local function transform (channel : number ): number
19- if channel >= 0.04045 then
20- return ((channel + 0.055 )/ (1 + 0.055 ))^ 2.4
21- else
19+ if channel < 0.04045 then
2220 return channel / 12.92
2321 end
22+
23+ return ((channel + 0.055 ) / 1.055 ) ^ 2.4
2424end
2525
2626-- Equivalent to f. Takes an sRGB channel and returns
2727-- the linear sRGB channel
2828local function inverse (channel : number ): number
29- if channel >= 0.0031308 then
30- return (1.055 ) * channel ^ (1.0 / 2.4 ) - 0.055
31- else
29+ if channel < 0.0031308 then
3230 return 12.92 * channel
3331 end
32+
33+ return (1.055 * channel ^ (1 / 2.4 )) - 0.055
3434end
3535
3636-- Uses a transformation to convert linear RGB into sRGB.
3737function sRGB .fromLinear (rgb : Color3 ): Color3
38- return Color3 .new (
39- transform (rgb .R ),
40- transform (rgb .G ),
41- transform (rgb .B )
42- )
38+ return Color3 .new (inverse (rgb .R ), inverse (rgb .G ), inverse (rgb .B ))
4339end
4440
4541-- Converts an sRGB into linear RGB using a
4642-- (The inverse of sRGB.fromLinear).
4743function sRGB .toLinear (srgb : Color3 ): Color3
48- return Color3 .new (
49- inverse (srgb .R ),
50- inverse (srgb .G ),
51- inverse (srgb .B )
52- )
44+ return Color3 .new (transform (srgb .R ), transform (srgb .G ), transform (srgb .B ))
5345end
5446
55- return sRGB
47+ return sRGB
You can’t perform that action at this time.
0 commit comments