Platform agnostic JavaScript implementation of BrickColor

@daw588/roblox-brick-color

Need to work with BrickColor outside Roblox? Can’t bear the pain of re-inventing the wheel yourself? Roblox Brick Color package got you covered. You can get the package from NPM registry, or rip it directly from the source code which is available on GitHub for all eyes to see, free of charge.

Source Code (GitHub) - https://github.com/Daw588/roblox-brick-color
Package (NPM) - https://www.npmjs.com/package/@daw588/roblox-brick-color


Getting Started

Install the package through the package manager of your choice. For this example, I chose NPM.

npm install @daw588/roblox-brick-color

Then just import the package and you’re all set.

import { BrickColor } from "@daw588/roblox-brick-color";

BrickColor.fromID(1); // BrickColor
BrickColor.fromName("White"); // BrickColor
BrickColor.fromRGB({ r: 243, g: 243, b: 243 }); // BrickColor

const whiteBrick = BrickColor.fromID(1); // BrickColor

whiteBrick.toID(); // 1
whiteBrick.toName(); // "White"
whiteBrick.toRGB(); // { r: 243, g: 243, b: 243 }
1 Like

Exactly what I need at the moment! Thank you!

Not to rain on your parade, but is this not the same as:

BrickColor.new("Really red").Color -- Color3
-- new BrickColor("Really red").Color

BrickColor.new(Color3.new(1, 0, 0)) -- Really red

BrickColor.new(Color3.fromRGB(255, 0, 0)).Number -- 1004

local color = BrickColor.new(1004).Color
color.R -- 1
Color.G -- 0
color.B -- 0

Although I can see outputting as a dictionary with the values already computed to be between 0-255 helpful.

This only works within Roblox. The library provides support for BrickColor outside Roblox.

That makes sense! I was under the assumption it was for Roblox TS, but I suppose there are practical use cases for where you might need BrickColors outside of Roblox.

Indeed. I have a Chrome extension that utilizes Roblox API, and some parts of it are outdated so they return BrickColor, which I need to convert to RGB. This is why I decided to make a package like this.

1 Like

I have updated the package to cover BrickColor names, and improved the API.