Skip to content

Instantly share code, notes, and snippets.

@ecurtiss
Last active August 1, 2021 03:26
Show Gist options
  • Save ecurtiss/74351d3498ba6dcab03f3e0d01576a19 to your computer and use it in GitHub Desktop.
Save ecurtiss/74351d3498ba6dcab03f3e0d01576a19 to your computer and use it in GitHub Desktop.
Visualize all unique Roblox Studio style guide colors
-- Visualize all unique Roblox Studio style guide colors
-- The color-modifier pairs associated with each color is listed under the color's Part
-- List of colors: https://developer.roblox.com/en-us/api-reference/enum/StudioStyleGuideColor
-- PASTE INTO THE COMMAND BAR
local Themes = settings().Studio:GetAvailableThemes()
local StudioStyleGuideColors = Enum.StudioStyleGuideColor:GetEnumItems()
local StudioStyleGuideModifiers = Enum.StudioStyleGuideModifier:GetEnumItems()
local PART_LENGTH = 4
local COLOR_OFFSET = 8
local THEME_OFFSET = COLOR_OFFSET * 2
local TEXT_SIZE = 16
local BILLBOARD_MAX_DISTANCE = 50
local DEC_TO_HEX_DIGITS = {[0] = "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
local function DecToHex(x)
local quotient = x / 16
return DEC_TO_HEX_DIGITS[math.floor(quotient)] .. DEC_TO_HEX_DIGITS[math.floor(16 * (quotient % 1))]
end
local UniqueColors = {}
local UniqueColorsSorted = {}
for _, theme in ipairs(Themes) do
local themeColors = {}
local themeColorsArray = {}
UniqueColors[theme] = themeColors
UniqueColorsSorted[theme] = themeColorsArray
for _, color in ipairs(StudioStyleGuideColors) do
for _, modifier in ipairs(StudioStyleGuideModifiers) do
local themeColor = theme:GetColor(color, modifier)
local themeVector = Vector3.new(
math.floor(themeColor.R * 255),
math.floor(themeColor.G * 255),
math.floor(themeColor.B * 255))
local name = color.Name .. "." .. modifier.Name
if themeColors[themeVector] then
table.insert(themeColors[themeVector], name)
else
themeColors[themeVector] = {name}
table.insert(themeColorsArray, themeVector)
end
end
end
table.sort(themeColorsArray, function(a, b)
-- sorting method #3 in the top reply of https://stackoverflow.com/questions/3014402/
local v = Vector3.new(math.sqrt(0.299), math.sqrt(0.587), math.sqrt(0.114))
return (v * a).Magnitude > (v * b).Magnitude
end)
end
local x = 1
for theme, themeColors in pairs(UniqueColorsSorted) do
for z, themeColor in ipairs(themeColors) do
local cframe = CFrame.new(
(x - 1) * THEME_OFFSET,
PART_LENGTH / 2,
(z - 1) * COLOR_OFFSET
)
local r, g, b = themeColor.X, themeColor.Y, themeColor.Z
local hex = "#" .. DecToHex(r) .. DecToHex(g) .. DecToHex(b)
local part = Instance.new("Part")
part.Anchored = true
part.BottomSurface = Enum.SurfaceType.Smooth
part.CFrame = cframe
part.Color = Color3.fromRGB(r, g, b)
part.Name = theme.Name .. hex
part.Size = Vector3.new(1, 1, 1) * PART_LENGTH
part.TopSurface = Enum.SurfaceType.Smooth
for _, colorModifierPair in ipairs(UniqueColors[theme][themeColor]) do
local stringValue = Instance.new("StringValue")
stringValue.Name = colorModifierPair
stringValue.Parent = part
end
local billboardGui = Instance.new("BillboardGui")
billboardGui.Adornee = part
billboardGui.AlwaysOnTop = true
billboardGui.ClipsDescendants = false
billboardGui.MaxDistance = BILLBOARD_MAX_DISTANCE
billboardGui.Size = UDim2.fromScale(4, 2)
billboardGui.StudsOffsetWorldSpace = Vector3.new(0, 4, 0)
billboardGui.Parent = part
local textLabel = Instance.new("TextLabel")
textLabel.BackgroundTransparency = 1
textLabel.Font = Enum.Font.GothamBold
textLabel.Size = UDim2.fromScale(1, 1)
textLabel.Text = string.format("%s, %s, %s\n%s", r, g, b, hex)
textLabel.TextColor3 = Color3.new(1, 1, 1)
textLabel.TextSize = TEXT_SIZE
textLabel.TextStrokeColor3 = Color3.new()
textLabel.TextStrokeTransparency = 0
textLabel.Parent = billboardGui
part.Parent = workspace
end
x += 1
end
game:GetService("ChangeHistoryService"):SetWaypoint("ShowStudioColors")
@ecurtiss
Copy link
Author

RobloxScreenShot20210529_035641977

You can search for a specific color-modifier pair.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment