Skip to main content

Color3Utils

Utility methods for Roblox Color3 values

Functions

getRelativeLuminance

Color3Utils.getRelativeLuminance(
colorColor3--

The Color3 to check

) → number--

A scalar from 0 to 1 with 0 as the darkest dark, and 1 as the whitest white

Luminance as per W3 per sRGB colorspace normalized with 0 as the darkest dark, and 1 as the whitest white.

See https://www.w3.org/TR/WCAG20/#relativeluminancedef

textShouldBeBlack

Color3Utils.textShouldBeBlack(
colorColor3--

The Color3 to check

) → boolean--

True if the text should be black, false if it should be good

Returns whether or not the text should be black using relative luminance as a metric.

See https://stackoverflow.com/questions/3942878/

scaleValue

Color3Utils.scaleValue(
color3Color3,
percentnumber--

Percent scaling

) → Color3

Scales the value component of hsv

setValue

Color3Utils.setValue(
color3Color3,
valuenumber
) → Color3

Sets the value component of hsv

setHue

Color3Utils.setHue(
color3Color3,
huenumber
) → Color3

Sets the hue component of hsv

scaleSaturation

Color3Utils.scaleSaturation(
color3Color3,
percentnumber--

Percent scaling

) → Color3

Scales the saturation component of hsv

setSaturation

Color3Utils.setSaturation(
color3Color3,
saturationnumber
) → Color3

Sets the saturation component of hsv

areEqual

Color3Utils.areEqual(
aColor3,
bColor3,
epsilonnumber?--

Optional

) → boolean

Compares 2 color3 values

toHexInteger

Color3Utils.toHexInteger(color3Color3) → number

Converts the color3 to the actual hex integer used in web and other areas.

toHexString

Color3Utils.toHexString(color3Color3) → number

Converts the color3 to the actual hex integer used in web and other areas.

Color3Utils.toHexString(Color3.fromRGB(0, 255, 0)) --> 00FF00

toWebHexString

Color3Utils.toWebHexString(color3Color3) → number

Converts the color3 to the standard web hex string

Color3Utils.toWebHexString(Color3.fromRGB(0, 255, 0)) --> #00FF00
Show raw api
{
    "functions": [
        {
            "name": "getRelativeLuminance",
            "desc": "Luminance as per W3 per sRGB colorspace normalized with 0\nas the darkest dark, and 1 as the whitest white.\n\nSee https://www.w3.org/TR/WCAG20/#relativeluminancedef",
            "params": [
                {
                    "name": "color",
                    "desc": "The Color3 to check",
                    "lua_type": "Color3"
                }
            ],
            "returns": [
                {
                    "desc": "A scalar from 0 to 1 with 0 as the darkest dark, and 1 as the whitest white",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 18,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        },
        {
            "name": "textShouldBeBlack",
            "desc": "Returns whether or not the text should be black using\nrelative luminance as a metric.\n\nSee https://stackoverflow.com/questions/3942878/",
            "params": [
                {
                    "name": "color",
                    "desc": "The Color3 to check",
                    "lua_type": "Color3"
                }
            ],
            "returns": [
                {
                    "desc": "True if the text should be black, false if it should be good",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 41,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        },
        {
            "name": "scaleValue",
            "desc": "Scales the value component of hsv",
            "params": [
                {
                    "name": "color3",
                    "desc": "",
                    "lua_type": "Color3"
                },
                {
                    "name": "percent",
                    "desc": "Percent scaling",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Color3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 51,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        },
        {
            "name": "setValue",
            "desc": "Sets the value component of hsv",
            "params": [
                {
                    "name": "color3",
                    "desc": "",
                    "lua_type": "Color3"
                },
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Color3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 62,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        },
        {
            "name": "setHue",
            "desc": "Sets the hue component of hsv",
            "params": [
                {
                    "name": "color3",
                    "desc": "",
                    "lua_type": "Color3"
                },
                {
                    "name": "hue",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Color3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 73,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        },
        {
            "name": "scaleSaturation",
            "desc": "Scales the saturation component of hsv",
            "params": [
                {
                    "name": "color3",
                    "desc": "",
                    "lua_type": "Color3"
                },
                {
                    "name": "percent",
                    "desc": "Percent scaling",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Color3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 84,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        },
        {
            "name": "setSaturation",
            "desc": "Sets the saturation component of hsv",
            "params": [
                {
                    "name": "color3",
                    "desc": "",
                    "lua_type": "Color3"
                },
                {
                    "name": "saturation",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Color3"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 95,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        },
        {
            "name": "areEqual",
            "desc": "Compares 2 color3 values",
            "params": [
                {
                    "name": "a",
                    "desc": "",
                    "lua_type": "Color3"
                },
                {
                    "name": "b",
                    "desc": "",
                    "lua_type": "Color3"
                },
                {
                    "name": "epsilon",
                    "desc": "Optional",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 108,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        },
        {
            "name": "toHexInteger",
            "desc": "Converts the color3 to the actual hex integer used in web and other\nareas.",
            "params": [
                {
                    "name": "color3",
                    "desc": "",
                    "lua_type": "Color3"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 125,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        },
        {
            "name": "toHexString",
            "desc": "Converts the color3 to the actual hex integer used in web and other\nareas.\n\n```\nColor3Utils.toHexString(Color3.fromRGB(0, 255, 0)) --> 00FF00\n```",
            "params": [
                {
                    "name": "color3",
                    "desc": "",
                    "lua_type": "Color3"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 142,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        },
        {
            "name": "toWebHexString",
            "desc": "Converts the color3 to the standard web hex string\n\n```\nColor3Utils.toWebHexString(Color3.fromRGB(0, 255, 0)) --> #00FF00\n```",
            "params": [
                {
                    "name": "color3",
                    "desc": "",
                    "lua_type": "Color3"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 158,
                "path": "src/color3utils/src/Shared/Color3Utils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Color3Utils",
    "desc": "Utility methods for Roblox Color3 values",
    "source": {
        "line": 5,
        "path": "src/color3utils/src/Shared/Color3Utils.lua"
    }
}