@quenty/colorpalette 10.6.3-canary.499.60b3012.0 → 10.6.3-canary.500.0c613a3.0
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 +5 -2
- package/package.json +11 -10
- package/src/Shared/ColorPalette.lua +56 -49
- package/src/Shared/Font/FontPalette.lua +19 -12
- package/src/Shared/Grade/ColorGradePalette.lua +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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
|
-
## [10.6.3-canary.
|
|
6
|
+
## [10.6.3-canary.500.0c613a3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/colorpalette@10.6.2...@quenty/colorpalette@10.6.3-canary.500.0c613a3.0) (2024-09-25)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Ensure backwards compatibility ([97995a8](https://github.com/Quenty/NevermoreEngine/commit/97995a812c8d1d8489104b16e7ac443fbb2effec))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/colorpalette",
|
|
3
|
-
"version": "10.6.3-canary.
|
|
3
|
+
"version": "10.6.3-canary.500.0c613a3.0",
|
|
4
4
|
"description": "Color palette system for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,17 +28,18 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/baseobject": "10.4.0",
|
|
32
|
-
"@quenty/blend": "12.5.3-canary.
|
|
33
|
-
"@quenty/color3utils": "11.5.3-canary.
|
|
34
|
-
"@quenty/colorpicker": "10.6.3-canary.
|
|
35
|
-
"@quenty/loader": "10.4.0",
|
|
31
|
+
"@quenty/baseobject": "10.4.1-canary.500.0c613a3.0",
|
|
32
|
+
"@quenty/blend": "12.5.3-canary.500.0c613a3.0",
|
|
33
|
+
"@quenty/color3utils": "11.5.3-canary.500.0c613a3.0",
|
|
34
|
+
"@quenty/colorpicker": "10.6.3-canary.500.0c613a3.0",
|
|
35
|
+
"@quenty/loader": "10.4.1-canary.500.0c613a3.0",
|
|
36
36
|
"@quenty/maid": "3.3.0",
|
|
37
37
|
"@quenty/math": "2.7.0",
|
|
38
|
-
"@quenty/
|
|
39
|
-
"@quenty/
|
|
38
|
+
"@quenty/observablecollection": "12.5.3-canary.500.0c613a3.0",
|
|
39
|
+
"@quenty/rx": "13.5.1-canary.500.0c613a3.0",
|
|
40
|
+
"@quenty/signal": "7.4.1-canary.500.0c613a3.0",
|
|
40
41
|
"@quenty/table": "3.5.0",
|
|
41
|
-
"@quenty/valueobject": "13.5.1-canary.
|
|
42
|
+
"@quenty/valueobject": "13.5.1-canary.500.0c613a3.0"
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "0c613a3ae0b6ba6a4cda511f572220bfa951c70d"
|
|
44
45
|
}
|
|
@@ -9,13 +9,11 @@ local ValueObject = require("ValueObject")
|
|
|
9
9
|
local ColorSwatch = require("ColorSwatch")
|
|
10
10
|
local ColorGradePalette = require("ColorGradePalette")
|
|
11
11
|
local Rx = require("Rx")
|
|
12
|
-
local Maid = require("Maid")
|
|
13
12
|
local Blend = require("Blend")
|
|
14
13
|
local Observable = require("Observable")
|
|
15
|
-
local Signal = require("Signal")
|
|
16
|
-
local Table = require("Table")
|
|
17
14
|
local ColorGradeUtils = require("ColorGradeUtils")
|
|
18
15
|
local LuvColor3Utils = require("LuvColor3Utils")
|
|
16
|
+
local ObservableMap = require("ObservableMap")
|
|
19
17
|
|
|
20
18
|
local ColorPalette = setmetatable({}, BaseObject)
|
|
21
19
|
ColorPalette.ClassName = "ColorPalette"
|
|
@@ -25,23 +23,20 @@ function ColorPalette.new()
|
|
|
25
23
|
local self = setmetatable(BaseObject.new(), ColorPalette)
|
|
26
24
|
|
|
27
25
|
self._gradePalette = self._maid:Add(ColorGradePalette.new())
|
|
28
|
-
self._gradeMaid = self._maid:Add(Maid.new())
|
|
29
|
-
self._colorMaid = self._maid:Add(Maid.new())
|
|
30
|
-
self._vividMaid = self._maid:Add(Maid.new())
|
|
31
26
|
|
|
32
|
-
self.
|
|
27
|
+
self._swatchMap = self._maid:Add(ObservableMap.new())
|
|
28
|
+
self._colorGradeMap = self._maid:Add(ObservableMap.new())
|
|
33
29
|
self._colorValues = {}
|
|
34
|
-
self._colorGradeValues = {}
|
|
35
30
|
self._vividnessValues = {}
|
|
36
31
|
|
|
37
|
-
self.ColorSwatchAdded = self.
|
|
38
|
-
self.ColorGradeAdded = self.
|
|
32
|
+
self.ColorSwatchAdded = assert(self._swatchMap.KeyAdded, "No KeyAdded") -- :Fire(name)
|
|
33
|
+
self.ColorGradeAdded = assert(self._colorGradeMap.KeyAdded, "No KeyAdded") -- :Fire(name) -- :Fire(name)
|
|
39
34
|
|
|
40
35
|
return self
|
|
41
36
|
end
|
|
42
37
|
|
|
43
38
|
function ColorPalette:GetSwatchNames()
|
|
44
|
-
return
|
|
39
|
+
return self._swatchMap:GetKeyList()
|
|
45
40
|
end
|
|
46
41
|
|
|
47
42
|
function ColorPalette:ObserveSwatchNames()
|
|
@@ -52,8 +47,20 @@ function ColorPalette:ObserveSwatchNames()
|
|
|
52
47
|
})
|
|
53
48
|
end
|
|
54
49
|
|
|
50
|
+
function ColorPalette:ObserveSwatchNameList()
|
|
51
|
+
return self._swatchMap:ObserveKeyList()
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
function ColorPalette:ObserveSwatchNamesBrio()
|
|
55
|
+
return self._swatchMap:ObserveKeysBrio()
|
|
56
|
+
end
|
|
57
|
+
|
|
55
58
|
function ColorPalette:GetGradeNames()
|
|
56
|
-
return
|
|
59
|
+
return self._colorGradeMap:GetKeyList()
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
function ColorPalette:ObserveGradeNameList()
|
|
63
|
+
return self._colorGradeMap:ObserveKeyList()
|
|
57
64
|
end
|
|
58
65
|
|
|
59
66
|
function ColorPalette:ObserveGradeNames()
|
|
@@ -64,6 +71,10 @@ function ColorPalette:ObserveGradeNames()
|
|
|
64
71
|
})
|
|
65
72
|
end
|
|
66
73
|
|
|
74
|
+
function ColorPalette:ObserveGradeNamesBrio()
|
|
75
|
+
return self._colorGradeMap:ObserveKeysBrio()
|
|
76
|
+
end
|
|
77
|
+
|
|
67
78
|
function ColorPalette:GetColorValues()
|
|
68
79
|
return self._colorValues
|
|
69
80
|
end
|
|
@@ -130,9 +141,9 @@ function ColorPalette:SetDefaultSurfaceName(surfaceName)
|
|
|
130
141
|
end
|
|
131
142
|
|
|
132
143
|
function ColorPalette:GetColorSwatch(colorName)
|
|
133
|
-
local swatch = self.
|
|
144
|
+
local swatch = self._swatchMap:Get(colorName)
|
|
134
145
|
if not swatch then
|
|
135
|
-
error(("No swatch with name %q"
|
|
146
|
+
error(string.format("No swatch with name %q", colorName))
|
|
136
147
|
end
|
|
137
148
|
|
|
138
149
|
return swatch
|
|
@@ -229,16 +240,16 @@ function ColorPalette:GetColorValue(colorName)
|
|
|
229
240
|
|
|
230
241
|
local colorValue = self._colorValues[colorName]
|
|
231
242
|
if not colorValue then
|
|
232
|
-
error(("No color with name %q"
|
|
243
|
+
error(string.format("No color with name %q", colorName))
|
|
233
244
|
end
|
|
234
245
|
|
|
235
246
|
return colorValue
|
|
236
247
|
end
|
|
237
248
|
|
|
238
249
|
function ColorPalette:GetGradeValue(gradeName)
|
|
239
|
-
local gradeValue = self.
|
|
250
|
+
local gradeValue = self._colorGradeMap:Get(gradeName)
|
|
240
251
|
if not gradeValue then
|
|
241
|
-
error(("No grade with name %q"
|
|
252
|
+
error(string.format("No grade with name %q", gradeName))
|
|
242
253
|
end
|
|
243
254
|
|
|
244
255
|
return gradeValue
|
|
@@ -247,7 +258,7 @@ end
|
|
|
247
258
|
function ColorPalette:GetVividnessValue(gradeName)
|
|
248
259
|
local vividnessValue = self._vividnessValues[gradeName]
|
|
249
260
|
if not vividnessValue then
|
|
250
|
-
error(("No grade with name %q"
|
|
261
|
+
error(string.format("No grade with name %q", gradeName))
|
|
251
262
|
end
|
|
252
263
|
|
|
253
264
|
return vividnessValue
|
|
@@ -273,43 +284,48 @@ end
|
|
|
273
284
|
function ColorPalette:GetSwatch(swatchName)
|
|
274
285
|
assert(type(swatchName) == "string", "Bad swatchName")
|
|
275
286
|
|
|
276
|
-
local swatch = self.
|
|
287
|
+
local swatch = self._swatchMap:Get(swatchName)
|
|
277
288
|
if not swatch then
|
|
278
|
-
error(("No swatch with name %q"
|
|
289
|
+
error(string.format("No swatch with name %q", swatchName))
|
|
279
290
|
end
|
|
280
291
|
|
|
281
292
|
return swatch
|
|
282
293
|
end
|
|
283
294
|
|
|
295
|
+
--[=[
|
|
296
|
+
@param colorName string
|
|
297
|
+
@param color Observable<Color3> | Color3
|
|
298
|
+
]=]
|
|
284
299
|
function ColorPalette:SetColor(colorName, color)
|
|
285
300
|
assert(type(colorName) == "string", "Bad colorName")
|
|
286
301
|
|
|
287
302
|
if not self._colorValues[colorName] then
|
|
288
|
-
error(("No color grade with name %q"
|
|
303
|
+
error(string.format("No color grade with name %q", colorName))
|
|
289
304
|
end
|
|
290
305
|
|
|
291
|
-
|
|
306
|
+
return self._colorValues[colorName]:Mount(color)
|
|
292
307
|
end
|
|
293
308
|
|
|
294
309
|
function ColorPalette:SetVividness(gradeName, vividness)
|
|
295
310
|
assert(type(gradeName) == "string", "Bad colorName")
|
|
296
311
|
|
|
297
312
|
if not self._vividnessValues[gradeName] then
|
|
298
|
-
error(("No vividness with name %q"
|
|
313
|
+
error(string.format("No vividness with name %q", gradeName))
|
|
299
314
|
end
|
|
300
315
|
|
|
301
|
-
|
|
316
|
+
return self._vividnessValues[gradeName]:Mount(vividness)
|
|
302
317
|
end
|
|
303
318
|
|
|
304
319
|
function ColorPalette:SetColorGrade(gradeName, grade)
|
|
305
320
|
assert(type(gradeName) == "string", "Bad colorName")
|
|
306
321
|
assert(grade, "Bad grade")
|
|
307
322
|
|
|
308
|
-
|
|
309
|
-
|
|
323
|
+
local gradeValue = self._colorGradeMap:Get(gradeName)
|
|
324
|
+
if not gradeValue then
|
|
325
|
+
error(string.format("No color grade with name %q", gradeName))
|
|
310
326
|
end
|
|
311
327
|
|
|
312
|
-
|
|
328
|
+
return gradeValue:Mount(grade)
|
|
313
329
|
end
|
|
314
330
|
|
|
315
331
|
|
|
@@ -322,26 +338,21 @@ end
|
|
|
322
338
|
function ColorPalette:DefineColorGrade(gradeName, gradeValue, vividnessValue)
|
|
323
339
|
assert(type(gradeName) == "string", "Bad gradeName")
|
|
324
340
|
|
|
325
|
-
if self.
|
|
326
|
-
warn(("[ColorPalette.DefineColorGrade] - Already defined grade of name %q"
|
|
341
|
+
if self._colorGradeMap:Get(gradeName) then
|
|
342
|
+
warn(string.format("[ColorPalette.DefineColorGrade] - Already defined grade of name %q", gradeName))
|
|
327
343
|
return
|
|
328
344
|
end
|
|
329
345
|
|
|
330
|
-
local colorGrade = ValueObject.new(0, "number")
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
local vividness = ValueObject.new(nil)
|
|
334
|
-
self._maid:GiveTask(vividness)
|
|
346
|
+
local colorGrade = self._maid:Add(ValueObject.new(0, "number"))
|
|
347
|
+
colorGrade:Mount(gradeValue or 0)
|
|
335
348
|
|
|
336
|
-
self.
|
|
349
|
+
local vividness = self._maid:Add(ValueObject.new(nil))
|
|
350
|
+
vividness:Mount(vividnessValue)
|
|
337
351
|
|
|
338
|
-
self._colorGradeValues[gradeName] = colorGrade
|
|
339
352
|
self._vividnessValues[gradeName] = vividness
|
|
340
353
|
|
|
341
|
-
self:
|
|
342
|
-
self:
|
|
343
|
-
|
|
344
|
-
self.ColorGradeAdded:Fire(gradeName)
|
|
354
|
+
self._gradePalette:Add(gradeName, colorGrade, vividness)
|
|
355
|
+
self._colorGradeMap:Set(gradeName, colorGrade)
|
|
345
356
|
|
|
346
357
|
return colorGrade
|
|
347
358
|
end
|
|
@@ -349,21 +360,17 @@ end
|
|
|
349
360
|
function ColorPalette:DefineColorSwatch(colorName, value)
|
|
350
361
|
assert(type(colorName) == "string", "Bad colorName")
|
|
351
362
|
|
|
352
|
-
if self.
|
|
353
|
-
warn(("[ColorPalette.DefineColorGrade] -Already defined color of name %q"
|
|
363
|
+
if self._swatchMap:Get(colorName) then
|
|
364
|
+
warn(string.format("[ColorPalette.DefineColorGrade] -Already defined color of name %q", colorName))
|
|
354
365
|
return
|
|
355
366
|
end
|
|
356
367
|
|
|
357
|
-
local colorValue = ValueObject.new(value or Color3.new(0, 0, 0), "Color3")
|
|
358
|
-
self._maid:
|
|
359
|
-
|
|
360
|
-
local colorSwatch = ColorSwatch.new(colorValue)
|
|
361
|
-
self._maid:GiveTask(colorSwatch)
|
|
368
|
+
local colorValue = self._maid:Add(ValueObject.new(value or Color3.new(0, 0, 0), "Color3"))
|
|
369
|
+
local colorSwatch = self._maid:Add(ColorSwatch.new(colorValue))
|
|
362
370
|
|
|
363
371
|
self._colorValues[colorName] = colorValue
|
|
364
|
-
self._swatches[colorName] = colorSwatch
|
|
365
372
|
|
|
366
|
-
self.
|
|
373
|
+
self._swatchMap:Set(colorName, colorSwatch)
|
|
367
374
|
|
|
368
375
|
return colorSwatch
|
|
369
376
|
end
|
|
@@ -7,10 +7,9 @@
|
|
|
7
7
|
local require = require(script.Parent.loader).load(script)
|
|
8
8
|
|
|
9
9
|
local BaseObject = require("BaseObject")
|
|
10
|
-
local Signal = require("Signal")
|
|
11
|
-
local Table = require("Table")
|
|
12
10
|
local Rx = require("Rx")
|
|
13
11
|
local ValueObject = require("ValueObject")
|
|
12
|
+
local ObservableSet = require("ObservableSet")
|
|
14
13
|
|
|
15
14
|
local FontPalette = setmetatable({}, BaseObject)
|
|
16
15
|
FontPalette.ClassName = "FontPalette"
|
|
@@ -28,7 +27,9 @@ function FontPalette.new()
|
|
|
28
27
|
self._fontFaces = {}
|
|
29
28
|
self._defaultFontMap = {} -- [name] = Enum.Font.?
|
|
30
29
|
|
|
31
|
-
self.
|
|
30
|
+
self._fontKeys = self._maid:Add(ObservableSet.new())
|
|
31
|
+
|
|
32
|
+
self.FontAdded = assert(self._fontKeys.ItemAdded, "No ItemAdded") -- :Fire(name)
|
|
32
33
|
|
|
33
34
|
return self
|
|
34
35
|
end
|
|
@@ -39,13 +40,12 @@ end
|
|
|
39
40
|
@return { string }
|
|
40
41
|
]=]
|
|
41
42
|
function FontPalette:GetFontNames()
|
|
42
|
-
return
|
|
43
|
+
return self._fontKeys:GetList()
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
--[=[
|
|
46
47
|
Observes all available font names as they are added starting with
|
|
47
48
|
existing fonts.
|
|
48
|
-
|
|
49
49
|
@return Observable<string>
|
|
50
50
|
]=]
|
|
51
51
|
function FontPalette:ObserveFontNames()
|
|
@@ -61,6 +61,16 @@ function FontPalette:ObserveFontNames()
|
|
|
61
61
|
})
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
+
--[=[
|
|
65
|
+
Observes all available font names as they are added starting with
|
|
66
|
+
existing fonts.
|
|
67
|
+
|
|
68
|
+
@return Observable<Brio<string>>
|
|
69
|
+
]=]
|
|
70
|
+
function FontPalette:ObserveFontNamesBrio()
|
|
71
|
+
return self._fontKeys:ObserveItemsBrio()
|
|
72
|
+
end
|
|
73
|
+
|
|
64
74
|
--[=[
|
|
65
75
|
Gets a font from name
|
|
66
76
|
|
|
@@ -165,7 +175,7 @@ function FontPalette:DefineFont(fontName, defaultFont)
|
|
|
165
175
|
assert(typeof(defaultFont) == "EnumItem" or typeof(defaultFont) == "Font", "Bad defaultFont")
|
|
166
176
|
|
|
167
177
|
if self._fonts[fontName] then
|
|
168
|
-
warn(("Already defined defaultFont of name %q"
|
|
178
|
+
warn(string.format("Already defined defaultFont of name %q", fontName))
|
|
169
179
|
return
|
|
170
180
|
end
|
|
171
181
|
|
|
@@ -181,11 +191,8 @@ function FontPalette:DefineFont(fontName, defaultFont)
|
|
|
181
191
|
error("Bad defaultFont")
|
|
182
192
|
end
|
|
183
193
|
|
|
184
|
-
local fontValue = ValueObject.new(defaultFontEnum)
|
|
185
|
-
self._maid:
|
|
186
|
-
|
|
187
|
-
local fontFaceValue = ValueObject.new(defaultFontFace)
|
|
188
|
-
self._maid:GiveTask(fontFaceValue)
|
|
194
|
+
local fontValue = self._maid:Add(ValueObject.new(defaultFontEnum))
|
|
195
|
+
local fontFaceValue = self._maid:Add(ValueObject.new(defaultFontFace))
|
|
189
196
|
|
|
190
197
|
self._fonts[fontName] = fontValue
|
|
191
198
|
self._fontFaces[fontName] = fontFaceValue
|
|
@@ -204,7 +211,7 @@ function FontPalette:DefineFont(fontName, defaultFont)
|
|
|
204
211
|
end
|
|
205
212
|
end))
|
|
206
213
|
|
|
207
|
-
self.
|
|
214
|
+
self._fontKeys:Add(fontName)
|
|
208
215
|
|
|
209
216
|
return fontValue
|
|
210
217
|
end
|
|
@@ -46,7 +46,7 @@ function ColorGradePalette:GetGrade(gradeName)
|
|
|
46
46
|
|
|
47
47
|
local observable = self._grades[gradeName]
|
|
48
48
|
if not observable then
|
|
49
|
-
error(("No grade for gradeName %q defined"
|
|
49
|
+
error(string.format("No grade for gradeName %q defined", gradeName))
|
|
50
50
|
return
|
|
51
51
|
end
|
|
52
52
|
|
|
@@ -57,7 +57,7 @@ function ColorGradePalette:GetGrade(gradeName)
|
|
|
57
57
|
|
|
58
58
|
local ok, grade = promise:Yield()
|
|
59
59
|
if not ok then
|
|
60
|
-
error(("Failed to retrieve grade %q due to %s"
|
|
60
|
+
error(string.format("Failed to retrieve grade %q due to %s", gradeName, tostring(grade)))
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
assert(type(grade) == "number", "Bad grade retrieved")
|
|
@@ -69,7 +69,7 @@ function ColorGradePalette:GetVividness(gradeName)
|
|
|
69
69
|
|
|
70
70
|
local observable = self._vividness[gradeName]
|
|
71
71
|
if not observable then
|
|
72
|
-
error(("No vividness for gradeName %q defined"
|
|
72
|
+
error(string.format("No vividness for gradeName %q defined", gradeName))
|
|
73
73
|
return
|
|
74
74
|
end
|
|
75
75
|
|
|
@@ -80,7 +80,7 @@ function ColorGradePalette:GetVividness(gradeName)
|
|
|
80
80
|
|
|
81
81
|
local ok, vividness = promise:Yield()
|
|
82
82
|
if not ok then
|
|
83
|
-
error(("Failed to retrieve vividness %q due to %s"
|
|
83
|
+
error(string.format("Failed to retrieve vividness %q due to %s", gradeName, tostring(vividness)))
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
assert(type(vividness) == "number", "Bad vividness retrieved")
|
|
@@ -98,7 +98,7 @@ function ColorGradePalette:ObserveGrade(gradeName)
|
|
|
98
98
|
assert(type(gradeName) == "string", "Bad gradeName")
|
|
99
99
|
|
|
100
100
|
if not self._grades[gradeName] then
|
|
101
|
-
error(("No grade for gradeName %q defined"
|
|
101
|
+
error(string.format("No grade for gradeName %q defined", gradeName))
|
|
102
102
|
return
|
|
103
103
|
end
|
|
104
104
|
|
|
@@ -196,7 +196,7 @@ function ColorGradePalette:_observeGradeFromName(gradeName)
|
|
|
196
196
|
})
|
|
197
197
|
end
|
|
198
198
|
|
|
199
|
-
error(("No grade for gradeName %q"
|
|
199
|
+
error(string.format("No grade for gradeName %q", tostring(gradeName)))
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
function ColorGradePalette:ObserveDefaultSurfaceGrade()
|