Skip to content

Commit 1ab31fb

Browse files
committed
Initial release
0 parents  commit 1ab31fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3227
-0
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ko_fi: Blupo
2+
patreon: Blupo

.github/workflows/create-release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
name: Create
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout main
14+
uses: actions/[email protected]
15+
with:
16+
submodules: true
17+
18+
- name: Setup Foreman
19+
uses: Roblox/[email protected]
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Build
24+
run: rojo build --output Color.rbxmx
25+
26+
- name: Create
27+
uses: anton-yurchenko/[email protected]
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
CHANGELOG_FILE: "docs/changelog.md"
31+
with:
32+
args: ./Color.rbxmx

.github/workflows/deploy-docs.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
name: Deploy
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout main
14+
uses: actions/[email protected]
15+
16+
- name: Deploy MkDocs
17+
uses: mhausenblas/[email protected]
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/upload-model.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Upload Plugin
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
name: Upload
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout main
14+
uses: actions/[email protected]
15+
with:
16+
submodules: true
17+
18+
- name: Setup Foreman
19+
uses: Roblox/[email protected]
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Upload
24+
run: rojo upload --cookie "$ROBLOSECURITY" --asset_id 7933448750
25+
env:
26+
ROBLOSECURITY: ${{ secrets.ROBLOSECURITY }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Roblox place files
2+
*.rbxm*
3+
*.rbxl*
4+
5+
# roblox.toml
6+
/roblox.toml

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "includes/t"]
2+
path = includes/t
3+
url = https://github.com/osyrisrblx/t
4+
[submodule "includes/testez"]
5+
path = includes/testez
6+
url = https://github.com/Roblox/testez/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Blupo
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Color
2+
3+
<a href="https://roblox.com/library/7933448750"><img src="https://img.shields.io/badge/roblox-model-green.svg" alt="Install" /></a>
4+
<a href="https://blupo.github.io/Color"><img src="https://img.shields.io/badge/docs-website-green.svg" alt="Documentation" /></a>
5+
6+
Color is a Roblox Luau library for color management and manipulation, inspired by [chroma.js](https://vis4.net/chromajs/). Some of its features include:
7+
8+
- Reading colors from many different formats
9+
- Converting colors to many different formats
10+
- Color interpolation in different spaces
11+
- Creating gradients
12+
13+
## All the constructors
14+
15+
Colors can be constructed how you would construct a normal Color3.
16+
17+
```lua
18+
local color = Color.new(1, 1, 1) -- or Color.from("RGB", 255, 255, 255)
19+
```
20+
21+
Alternatively, you can construct them from different color types using [Color.from](https://blupo.github.io/Color/api/color/#colorfrom). The list of available color types is available in the [Color Types](https://blupo.github.io/Color/api/color/#color-types) section of the API reference.
22+
23+
```lua
24+
local color3Equivalent = Color.from("Color3", Color3.new(1, 1, 1))
25+
local brickColorEquivalent = Color.from("BrickColor", BrickColor.random())
26+
27+
local hsvColor = Color.from("HSV", 120, 1, 1)
28+
local hslColor = Color.from("HSL", 120, 1, 0.5)
29+
30+
local hexColor = Color.from("Hex", "6e05ff")
31+
32+
local tempColor = Color.from("Temperature", 6500)
33+
34+
local randomColor = Color.random() -- we also have random colors
35+
```
36+
37+
## All the conversions
38+
39+
Likewise, every color type can also be converted to, using [Color.to](https://blupo.github.io/Color/api/color/#colorto).
40+
41+
```lua
42+
local color = Color.from("Hex", "ff69b4")
43+
44+
color:to("BrickColor") --> BrickColor.new("Pink")
45+
color:to("Color3") --> Color3.fromRGB(255, 105, 180)
46+
color:to("HSV") --> 330, 0.58824, 1
47+
color:to("HSL") --> 330, 1, 0.70588
48+
color:to("Hex") --> ff69b4 (obviously)
49+
color:to("Temperature") --> 4358
50+
```
51+
52+
## Better interpolation
53+
54+
RGB interpolations (e.g. using [Color3.Lerp](https://developer.roblox.com/en-us/api-reference/datatype/Color3#functions)) can result in grey or dark intermediate colors. Using linear RGB interpolation or perceptually uniform color spaces such as [CIELAB](https://en.wikipedia.org/wiki/CIELAB_color_space) or [CIELUV](https://en.wikipedia.org/wiki/CIELUV) can help avoid these problems.
55+
56+
![RGB interpolation between red and green](docs/images/rgb-interpolation.png)
57+
58+
![lRGB interpolation between red and green](docs/images/lrgb-interpolation.png)
59+
60+
![CIELAB interpolation between red and green](docs/images/lab-interpolation.png)
61+
62+
Interpolations can be done using [Color.mix](https://blupo.github.io/Color/api/color/#colormix).
63+
64+
```lua
65+
local red = Color.new(1, 0, 0)
66+
local green = Color.new(0, 1, 0)
67+
68+
red:mix(green, 0.5)
69+
red:mix(green, 0.5, "lRGB")
70+
red:mix(green, 0.5, "Lab")
71+
```
72+
73+
## Gradients
74+
75+
Gradients are lists of Colors that can be used for generating intermediate Colors or ColorSequences. You can read its API reference [here](https://blupo.github.io/Color/api/gradient/).
76+
77+
```lua
78+
local color1 = Color.from("Hex", "4cbbfc")
79+
local color2 = Color.from("Hex", "47af22")
80+
local color3 = Color.from("Hex", "0000ff")
81+
local gradient = Color.gradientFromColors(color1, color2, color3)
82+
83+
local aColor = gradient:color(0.5, "lRGB")
84+
local manyColors = gradient:colors(10, "lRGB")
85+
86+
local cs = gradient:toColorSequence(20, "lRGB")
87+
```
88+
89+
## Installing
90+
91+
The module is available in the library [here](https://roblox.com/library/7933448750). You can also grab a [release](https://github.com/Blupo/Color/releases) from GitHub and install it manually.
92+
93+
If you know how to use [Rojo](https://rojo.space), you can build the latest code from the development branch to get the newest features. Keep in mind that this is **development code**, and things can break or change quickly.

default.project.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "Color",
3+
4+
"tree": {
5+
"$path": "src",
6+
7+
"t": {
8+
"$path": "includes/t"
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)