@quenty/color3utils 11.17.0 → 11.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +6 -6
- package/src/Shared/Color3Utils.lua +28 -29
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [11.17.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/color3utils@11.17.0...@quenty/color3utils@11.17.1) (2025-03-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/color3utils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [11.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/color3utils@11.16.0...@quenty/color3utils@11.17.0) (2025-02-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @quenty/color3utils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/color3utils",
|
|
3
|
-
"version": "11.17.
|
|
3
|
+
"version": "11.17.1",
|
|
4
4
|
"description": "Utility methods for Roblox Color3 values",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/blend": "^12.17.
|
|
31
|
+
"@quenty/blend": "^12.17.1",
|
|
32
32
|
"@quenty/loader": "^10.8.0",
|
|
33
33
|
"@quenty/maid": "^3.4.0",
|
|
34
|
-
"@quenty/math": "^2.7.
|
|
35
|
-
"@quenty/rx": "^13.16.
|
|
36
|
-
"@quenty/valueobject": "^13.16.
|
|
34
|
+
"@quenty/math": "^2.7.1",
|
|
35
|
+
"@quenty/rx": "^13.16.1",
|
|
36
|
+
"@quenty/valueobject": "^13.16.1"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "6b7c3e15e60cdb185986207b574e2b5591261e7a"
|
|
39
39
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Utility methods for Roblox Color3 values
|
|
3
4
|
@class Color3Utils
|
|
@@ -15,14 +16,14 @@ local Color3Utils = {}
|
|
|
15
16
|
@return number -- A scalar from 0 to 1 with 0 as the darkest dark, and 1 as the whitest white
|
|
16
17
|
|
|
17
18
|
]=]
|
|
18
|
-
function Color3Utils.getRelativeLuminance(color)
|
|
19
|
-
local components = { color.
|
|
19
|
+
function Color3Utils.getRelativeLuminance(color: Color3): number
|
|
20
|
+
local components = { color.R, color.G, color.B }
|
|
20
21
|
local vals = {}
|
|
21
22
|
for i, val in pairs(components) do
|
|
22
23
|
if val <= 0.03928 then
|
|
23
|
-
vals[i] = val/12.92
|
|
24
|
+
vals[i] = val / 12.92
|
|
24
25
|
else
|
|
25
|
-
vals[i] = ((val+0.055)/1.055) ^ 2.4
|
|
26
|
+
vals[i] = ((val + 0.055) / 1.055) ^ 2.4
|
|
26
27
|
end
|
|
27
28
|
end
|
|
28
29
|
|
|
@@ -38,7 +39,7 @@ end
|
|
|
38
39
|
@param color Color3 -- The Color3 to check
|
|
39
40
|
@return boolean -- True if the text should be black, false if it should be good
|
|
40
41
|
]=]
|
|
41
|
-
function Color3Utils.textShouldBeBlack(color)
|
|
42
|
+
function Color3Utils.textShouldBeBlack(color: Color3): boolean
|
|
42
43
|
return Color3Utils.getRelativeLuminance(color) > 0.179
|
|
43
44
|
end
|
|
44
45
|
|
|
@@ -48,9 +49,9 @@ end
|
|
|
48
49
|
@param percent number -- Percent scaling
|
|
49
50
|
@return Color3
|
|
50
51
|
]=]
|
|
51
|
-
function Color3Utils.scaleValue(color3, percent)
|
|
52
|
-
local h, s, v =
|
|
53
|
-
return Color3.fromHSV(h, s, percent*v)
|
|
52
|
+
function Color3Utils.scaleValue(color3: Color3, percent: number): Color3
|
|
53
|
+
local h, s, v = color3:ToHSV()
|
|
54
|
+
return Color3.fromHSV(h, s, percent * v)
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
--[=[
|
|
@@ -59,8 +60,8 @@ end
|
|
|
59
60
|
@param value number
|
|
60
61
|
@return Color3
|
|
61
62
|
]=]
|
|
62
|
-
function Color3Utils.setValue(color3, value)
|
|
63
|
-
local h, s, _ =
|
|
63
|
+
function Color3Utils.setValue(color3: Color3, value: number): Color3
|
|
64
|
+
local h, s, _ = color3:ToHSV()
|
|
64
65
|
return Color3.fromHSV(h, s, value)
|
|
65
66
|
end
|
|
66
67
|
|
|
@@ -70,8 +71,8 @@ end
|
|
|
70
71
|
@param hue number
|
|
71
72
|
@return Color3
|
|
72
73
|
]=]
|
|
73
|
-
function Color3Utils.setHue(color3, hue)
|
|
74
|
-
local _, s, v =
|
|
74
|
+
function Color3Utils.setHue(color3: Color3, hue: number): Color3
|
|
75
|
+
local _, s, v = color3:ToHSV()
|
|
75
76
|
return Color3.fromHSV(hue, s, v)
|
|
76
77
|
end
|
|
77
78
|
|
|
@@ -81,9 +82,9 @@ end
|
|
|
81
82
|
@param percent number -- Percent scaling
|
|
82
83
|
@return Color3
|
|
83
84
|
]=]
|
|
84
|
-
function Color3Utils.scaleSaturation(color3, percent)
|
|
85
|
-
local h, s, v =
|
|
86
|
-
return Color3.fromHSV(h, percent*s, v)
|
|
85
|
+
function Color3Utils.scaleSaturation(color3: Color3, percent: number): Color3
|
|
86
|
+
local h, s, v = color3:ToHSV()
|
|
87
|
+
return Color3.fromHSV(h, percent * s, v)
|
|
87
88
|
end
|
|
88
89
|
|
|
89
90
|
--[=[
|
|
@@ -92,8 +93,8 @@ end
|
|
|
92
93
|
@param saturation number
|
|
93
94
|
@return Color3
|
|
94
95
|
]=]
|
|
95
|
-
function Color3Utils.setSaturation(color3, saturation)
|
|
96
|
-
local h, _, v =
|
|
96
|
+
function Color3Utils.setSaturation(color3: Color3, saturation: number): Color3
|
|
97
|
+
local h, _, v = color3:ToHSV()
|
|
97
98
|
return Color3.fromHSV(h, saturation, v)
|
|
98
99
|
end
|
|
99
100
|
|
|
@@ -105,14 +106,12 @@ end
|
|
|
105
106
|
@param epsilon number? -- Optional
|
|
106
107
|
@return boolean
|
|
107
108
|
]=]
|
|
108
|
-
function Color3Utils.areEqual(a, b, epsilon)
|
|
109
|
-
if
|
|
110
|
-
epsilon = 1e-6
|
|
111
|
-
end
|
|
109
|
+
function Color3Utils.areEqual(a: Color3, b: Color3, epsilon: number?): boolean
|
|
110
|
+
local equalEpsilon = if epsilon then epsilon else 1e-6
|
|
112
111
|
|
|
113
|
-
return math.abs(a.
|
|
114
|
-
and math.abs(a.
|
|
115
|
-
and math.abs(a.
|
|
112
|
+
return math.abs(a.R - b.R) <= equalEpsilon
|
|
113
|
+
and math.abs(a.G - b.G) <= equalEpsilon
|
|
114
|
+
and math.abs(a.B - b.B) <= equalEpsilon
|
|
116
115
|
end
|
|
117
116
|
|
|
118
117
|
--[=[
|
|
@@ -122,10 +121,10 @@ end
|
|
|
122
121
|
@param color3 Color3
|
|
123
122
|
@return number
|
|
124
123
|
]=]
|
|
125
|
-
function Color3Utils.toHexInteger(color3)
|
|
124
|
+
function Color3Utils.toHexInteger(color3: Color3): number
|
|
126
125
|
assert(typeof(color3) == "Color3", "Bad color3")
|
|
127
126
|
|
|
128
|
-
return bit32.bor(bit32.lshift(color3.
|
|
127
|
+
return bit32.bor(bit32.lshift(color3.R * 0xFF, 16), bit32.lshift(color3.G * 0xFF, 8), color3.B * 0xFF)
|
|
129
128
|
end
|
|
130
129
|
|
|
131
130
|
--[=[
|
|
@@ -139,7 +138,7 @@ end
|
|
|
139
138
|
@param color3 Color3
|
|
140
139
|
@return number
|
|
141
140
|
]=]
|
|
142
|
-
function Color3Utils.toHexString(color3)
|
|
141
|
+
function Color3Utils.toHexString(color3: Color3): string
|
|
143
142
|
assert(typeof(color3) == "Color3", "Bad color3")
|
|
144
143
|
|
|
145
144
|
return string.format("%06X", Color3Utils.toHexInteger(color3))
|
|
@@ -155,10 +154,10 @@ end
|
|
|
155
154
|
@param color3 Color3
|
|
156
155
|
@return number
|
|
157
156
|
]=]
|
|
158
|
-
function Color3Utils.toWebHexString(color3)
|
|
157
|
+
function Color3Utils.toWebHexString(color3: Color3): string
|
|
159
158
|
assert(typeof(color3) == "Color3", "Bad color3")
|
|
160
159
|
|
|
161
160
|
return string.format("#%06X", Color3Utils.toHexInteger(color3))
|
|
162
161
|
end
|
|
163
162
|
|
|
164
|
-
return Color3Utils
|
|
163
|
+
return Color3Utils
|