@quenty/colorpalette 10.21.3 → 10.21.4-canary.559.339cfa7.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 +16 -0
- package/package.json +14 -14
- package/src/Shared/ColorPalette.lua +84 -61
- package/src/Shared/ColorPalette.story.lua +125 -116
- package/src/Shared/Font/FontPalette.lua +47 -28
- package/src/Shared/Grade/ColorGradePalette.lua +30 -21
- package/src/Shared/Grade/ColorGradePalette.story.lua +118 -107
- package/src/Shared/Grade/ColorGradeUtils.lua +3 -3
- package/src/Shared/Swatch/ColorSwatch.lua +38 -27
- package/src/Shared/Swatch/ColorSwatch.story.lua +57 -55
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
@class ColorGradePalette.story
|
|
3
3
|
]]
|
|
4
4
|
|
|
5
|
-
local require =
|
|
5
|
+
local require =
|
|
6
|
+
require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
|
|
6
7
|
|
|
7
|
-
local Maid = require("Maid")
|
|
8
8
|
local Blend = require("Blend")
|
|
9
9
|
local ColorGradePalette = require("ColorGradePalette")
|
|
10
|
-
local ColorSwatch = require("ColorSwatch")
|
|
11
10
|
local ColorPickerStoryUtils = require("ColorPickerStoryUtils")
|
|
11
|
+
local ColorSwatch = require("ColorSwatch")
|
|
12
|
+
local Maid = require("Maid")
|
|
12
13
|
local ValueObject = require("ValueObject")
|
|
13
14
|
|
|
14
15
|
return function(target)
|
|
@@ -59,163 +60,173 @@ return function(target)
|
|
|
59
60
|
local percentMouseOver = Blend.Spring(mouseOver, 60)
|
|
60
61
|
|
|
61
62
|
return Blend.New "Frame" {
|
|
62
|
-
BackgroundColor3 = surface:ObserveGraded(gradePalette:ObserveGrade("surface"))
|
|
63
|
-
Size = UDim2.new(0, 250, 0, 100)
|
|
63
|
+
BackgroundColor3 = surface:ObserveGraded(gradePalette:ObserveGrade("surface")),
|
|
64
|
+
Size = UDim2.new(0, 250, 0, 100),
|
|
64
65
|
|
|
65
66
|
[Blend.Children] = {
|
|
66
67
|
Blend.New "TextLabel" {
|
|
67
|
-
TextColor3 = text:ObserveGraded(gradePalette:ObserveGrade("text"))
|
|
68
|
-
Text = labelText
|
|
69
|
-
Font = Enum.Font.FredokaOne
|
|
70
|
-
Size = UDim2.new(1, 0, 1, 0)
|
|
71
|
-
BackgroundTransparency = 1
|
|
72
|
-
TextScaled = true
|
|
73
|
-
ZIndex = 2
|
|
74
|
-
}
|
|
68
|
+
TextColor3 = text:ObserveGraded(gradePalette:ObserveGrade("text")),
|
|
69
|
+
Text = labelText,
|
|
70
|
+
Font = Enum.Font.FredokaOne,
|
|
71
|
+
Size = UDim2.new(1, 0, 1, 0),
|
|
72
|
+
BackgroundTransparency = 1,
|
|
73
|
+
TextScaled = true,
|
|
74
|
+
ZIndex = 2,
|
|
75
|
+
},
|
|
75
76
|
|
|
76
77
|
Blend.New "UIPadding" {
|
|
77
|
-
PaddingTop = UDim.new(0, 10)
|
|
78
|
-
PaddingBottom = UDim.new(0, 10)
|
|
79
|
-
PaddingLeft = UDim.new(0, 10)
|
|
80
|
-
PaddingRight = UDim.new(0, 10)
|
|
81
|
-
}
|
|
78
|
+
PaddingTop = UDim.new(0, 10),
|
|
79
|
+
PaddingBottom = UDim.new(0, 10),
|
|
80
|
+
PaddingLeft = UDim.new(0, 10),
|
|
81
|
+
PaddingRight = UDim.new(0, 10),
|
|
82
|
+
},
|
|
82
83
|
|
|
83
84
|
Blend.New "UIStroke" {
|
|
84
|
-
Color = surface:ObserveGraded(gradePalette:ObserveGrade("border"))
|
|
85
|
-
Thickness = 5
|
|
86
|
-
}
|
|
85
|
+
Color = surface:ObserveGraded(gradePalette:ObserveGrade("border")),
|
|
86
|
+
Thickness = 5,
|
|
87
|
+
},
|
|
87
88
|
|
|
88
89
|
Blend.New "UICorner" {
|
|
89
|
-
CornerRadius = UDim.new(0, 10)
|
|
90
|
-
}
|
|
90
|
+
CornerRadius = UDim.new(0, 10),
|
|
91
|
+
},
|
|
91
92
|
|
|
92
93
|
Blend.New "Frame" {
|
|
93
|
-
Name = "Highlight"
|
|
94
|
-
Size = UDim2.new(0.8, 0, 0, 20)
|
|
95
|
-
Position = UDim2.fromScale(0.5, 0.75)
|
|
96
|
-
AnchorPoint = Vector2.new(0.5, 0.5)
|
|
97
|
-
BackgroundColor3 = accent:ObserveGraded(gradePalette:ObserveGrade("highlight"))
|
|
94
|
+
Name = "Highlight",
|
|
95
|
+
Size = UDim2.new(0.8, 0, 0, 20),
|
|
96
|
+
Position = UDim2.fromScale(0.5, 0.75),
|
|
97
|
+
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
98
|
+
BackgroundColor3 = accent:ObserveGraded(gradePalette:ObserveGrade("highlight")),
|
|
98
99
|
[Blend.Children] = {
|
|
99
100
|
Blend.New "UICorner" {
|
|
100
|
-
CornerRadius = UDim.new(0, 10)
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
101
|
+
CornerRadius = UDim.new(0, 10),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
104
105
|
|
|
105
106
|
Blend.New "Frame" {
|
|
106
|
-
Name ="Button"
|
|
107
|
-
Size = UDim2.new(0.5, 0, 0, 40)
|
|
108
|
-
AnchorPoint = Vector2.new(1, 1)
|
|
109
|
-
BackgroundColor3 = action:ObserveGraded(
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
Name = "Button",
|
|
108
|
+
Size = UDim2.new(0.5, 0, 0, 40),
|
|
109
|
+
AnchorPoint = Vector2.new(1, 1),
|
|
110
|
+
BackgroundColor3 = action:ObserveGraded(
|
|
111
|
+
gradePalette:ObserveModified("action", "mouseOver", percentMouseOver)
|
|
112
|
+
),
|
|
113
|
+
Position = UDim2.new(1, 30, 1, 40),
|
|
114
|
+
ZIndex = 2,
|
|
112
115
|
|
|
113
116
|
[Blend.OnEvent "MouseEnter"] = function()
|
|
114
117
|
mouseOver.Value = 1
|
|
115
|
-
end
|
|
118
|
+
end,
|
|
116
119
|
|
|
117
120
|
[Blend.OnEvent "MouseLeave"] = function()
|
|
118
121
|
mouseOver.Value = 0
|
|
119
|
-
end
|
|
122
|
+
end,
|
|
120
123
|
|
|
121
124
|
[Blend.Children] = {
|
|
122
125
|
Blend.New "UICorner" {
|
|
123
|
-
CornerRadius = UDim.new(0, 10)
|
|
124
|
-
}
|
|
126
|
+
CornerRadius = UDim.new(0, 10),
|
|
127
|
+
},
|
|
125
128
|
|
|
126
129
|
Blend.New "TextLabel" {
|
|
127
|
-
TextColor3 = action:ObserveGraded(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
TextColor3 = action:ObserveGraded(
|
|
131
|
+
gradePalette:ObserveModified(
|
|
132
|
+
gradePalette:ObserveOn("text", "action"),
|
|
133
|
+
"mouseOver",
|
|
134
|
+
percentMouseOver
|
|
135
|
+
)
|
|
136
|
+
),
|
|
137
|
+
Text = "Action",
|
|
138
|
+
TextScaled = true,
|
|
139
|
+
Font = Enum.Font.FredokaOne,
|
|
140
|
+
Size = UDim2.new(1, 0, 1, 0),
|
|
141
|
+
BackgroundTransparency = 1,
|
|
142
|
+
ZIndex = 2,
|
|
143
|
+
},
|
|
135
144
|
|
|
136
145
|
[Blend.Children] = {
|
|
137
146
|
Blend.New "UIStroke" {
|
|
138
|
-
Color = action:ObserveGraded(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
Color = action:ObserveGraded(
|
|
148
|
+
gradePalette:ObserveModified(
|
|
149
|
+
gradePalette:ObserveOn("border", "action"),
|
|
150
|
+
"mouseOver",
|
|
151
|
+
percentMouseOver
|
|
152
|
+
)
|
|
153
|
+
),
|
|
154
|
+
Thickness = 5,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
142
157
|
|
|
143
158
|
Blend.New "Frame" {
|
|
144
|
-
Name = "Highlight"
|
|
145
|
-
Size = UDim2.new(0.9, 0, 0, 10)
|
|
146
|
-
Position = UDim2.fromScale(0.5, 0.75)
|
|
147
|
-
AnchorPoint = Vector2.new(0.5, 0.5)
|
|
148
|
-
BackgroundColor3 = accent:ObserveGraded(gradePalette:ObserveOn("highlight", "action"))
|
|
159
|
+
Name = "Highlight",
|
|
160
|
+
Size = UDim2.new(0.9, 0, 0, 10),
|
|
161
|
+
Position = UDim2.fromScale(0.5, 0.75),
|
|
162
|
+
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
163
|
+
BackgroundColor3 = accent:ObserveGraded(gradePalette:ObserveOn("highlight", "action")),
|
|
149
164
|
[Blend.Children] = {
|
|
150
165
|
Blend.New "UICorner" {
|
|
151
|
-
CornerRadius = UDim.new(0, 10)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
166
|
+
CornerRadius = UDim.new(0, 10),
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
156
170
|
|
|
157
171
|
Blend.New "UIPadding" {
|
|
158
|
-
PaddingTop = UDim.new(0, 5)
|
|
159
|
-
PaddingBottom = UDim.new(0, 5)
|
|
160
|
-
PaddingLeft = UDim.new(0, 5)
|
|
161
|
-
PaddingRight = UDim.new(0, 5)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
172
|
+
PaddingTop = UDim.new(0, 5),
|
|
173
|
+
PaddingBottom = UDim.new(0, 5),
|
|
174
|
+
PaddingLeft = UDim.new(0, 5),
|
|
175
|
+
PaddingRight = UDim.new(0, 5),
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
}
|
|
167
181
|
end
|
|
168
182
|
|
|
169
183
|
maid:GiveTask((Blend.New "ScrollingFrame" {
|
|
170
|
-
Size = UDim2.new(1, 0, 1, 0)
|
|
171
|
-
BackgroundColor3 = Color3.new(0, 0, 0)
|
|
172
|
-
AutomaticCanvasSize = Enum.AutomaticSize.Y
|
|
173
|
-
CanvasSize = UDim2.new(1, 0, 0, 0)
|
|
174
|
-
Parent = target
|
|
184
|
+
Size = UDim2.new(1, 0, 1, 0),
|
|
185
|
+
BackgroundColor3 = Color3.new(0, 0, 0),
|
|
186
|
+
AutomaticCanvasSize = Enum.AutomaticSize.Y,
|
|
187
|
+
CanvasSize = UDim2.new(1, 0, 0, 0),
|
|
188
|
+
Parent = target,
|
|
175
189
|
|
|
176
190
|
[Blend.Children] = {
|
|
177
191
|
ColorPickerStoryUtils.create(maid, function(createPicker)
|
|
178
|
-
createPicker("Surface", surfaceColorValue)
|
|
179
|
-
createPicker("Text", textColorValue)
|
|
180
|
-
createPicker("Accent", accentColorValue)
|
|
181
|
-
createPicker("Action", actionColorValue)
|
|
182
|
-
end)
|
|
183
|
-
|
|
192
|
+
createPicker("Surface", surfaceColorValue)
|
|
193
|
+
createPicker("Text", textColorValue)
|
|
194
|
+
createPicker("Accent", accentColorValue)
|
|
195
|
+
createPicker("Action", actionColorValue)
|
|
196
|
+
end),
|
|
184
197
|
|
|
185
198
|
Blend.New "Frame" {
|
|
186
|
-
Size = UDim2.new(1, 0, 0, 0)
|
|
187
|
-
BackgroundTransparency = 1
|
|
188
|
-
AutomaticSize = Enum.AutomaticSize.Y
|
|
199
|
+
Size = UDim2.new(1, 0, 0, 0),
|
|
200
|
+
BackgroundTransparency = 1,
|
|
201
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
189
202
|
|
|
190
203
|
[Blend.Children] = {
|
|
191
|
-
sampleGui("Light", light)
|
|
192
|
-
sampleGui("Dark", dark)
|
|
204
|
+
sampleGui("Light", light),
|
|
205
|
+
sampleGui("Dark", dark),
|
|
193
206
|
|
|
194
207
|
Blend.New "UIListLayout" {
|
|
195
|
-
Padding = UDim.new(0, 50)
|
|
196
|
-
HorizontalAlignment = Enum.HorizontalAlignment.Center
|
|
197
|
-
VerticalAlignment = Enum.VerticalAlignment.Top
|
|
198
|
-
FillDirection = Enum.FillDirection.Vertical
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
208
|
+
Padding = UDim.new(0, 50),
|
|
209
|
+
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
|
210
|
+
VerticalAlignment = Enum.VerticalAlignment.Top,
|
|
211
|
+
FillDirection = Enum.FillDirection.Vertical,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
203
215
|
|
|
204
216
|
Blend.New "UIListLayout" {
|
|
205
|
-
Padding = UDim.new(0, 20)
|
|
206
|
-
HorizontalAlignment = Enum.HorizontalAlignment.Center
|
|
207
|
-
VerticalAlignment = Enum.VerticalAlignment.Top
|
|
208
|
-
FillDirection = Enum.FillDirection.Vertical
|
|
209
|
-
}
|
|
217
|
+
Padding = UDim.new(0, 20),
|
|
218
|
+
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
|
219
|
+
VerticalAlignment = Enum.VerticalAlignment.Top,
|
|
220
|
+
FillDirection = Enum.FillDirection.Vertical,
|
|
221
|
+
},
|
|
210
222
|
|
|
211
223
|
Blend.New "UIPadding" {
|
|
212
|
-
PaddingTop = UDim.new(0, 10)
|
|
213
|
-
}
|
|
214
|
-
}
|
|
224
|
+
PaddingTop = UDim.new(0, 10),
|
|
225
|
+
},
|
|
226
|
+
},
|
|
215
227
|
}):Subscribe())
|
|
216
228
|
|
|
217
|
-
|
|
218
229
|
return function()
|
|
219
230
|
maid:DoCleaning()
|
|
220
231
|
end
|
|
221
|
-
end
|
|
232
|
+
end
|
|
@@ -126,12 +126,12 @@ function ColorGradeUtils.getGradedColor(baseColor: Color3, colorGrade: number, v
|
|
|
126
126
|
-- local towardsOffset = (colorGrade - v)/100
|
|
127
127
|
-- local scaleTowards = math.clamp(math.abs(towardsOffset), 0, 1)^vividness
|
|
128
128
|
-- u = math.clamp(Math.map(scaleTowards, 0, 1, u, 0), 0, 100)
|
|
129
|
-
u = math.clamp(vividness*u, 0, 100)
|
|
129
|
+
u = math.clamp(vividness * u, 0, 100)
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
v = 100 - colorGrade
|
|
133
133
|
|
|
134
|
-
return LuvColor3Utils.toColor3({l, u, v})
|
|
134
|
+
return LuvColor3Utils.toColor3({ l, u, v })
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
-
return ColorGradeUtils
|
|
137
|
+
return ColorGradeUtils
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Provides variants of a given color. In painting a swatch contains different shades of the same color.
|
|
3
4
|
The same idea is here, except we can provide many variants of a color, with different vividness and brightness
|
|
@@ -9,23 +10,31 @@
|
|
|
9
10
|
local require = require(script.Parent.loader).load(script)
|
|
10
11
|
|
|
11
12
|
local BaseObject = require("BaseObject")
|
|
12
|
-
local ValueObject = require("ValueObject")
|
|
13
13
|
local Blend = require("Blend")
|
|
14
|
-
local LuvColor3Utils = require("LuvColor3Utils")
|
|
15
14
|
local ColorGradeUtils = require("ColorGradeUtils")
|
|
16
|
-
local
|
|
15
|
+
local LuvColor3Utils = require("LuvColor3Utils")
|
|
17
16
|
local Observable = require("Observable")
|
|
17
|
+
local Rx = require("Rx")
|
|
18
|
+
local Signal = require("Signal")
|
|
19
|
+
local ValueObject = require("ValueObject")
|
|
18
20
|
|
|
19
21
|
local ColorSwatch = setmetatable({}, BaseObject)
|
|
20
22
|
ColorSwatch.ClassName = "ColorSwatch"
|
|
21
23
|
ColorSwatch.__index = ColorSwatch
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
export type ColorSwatch = typeof(setmetatable(
|
|
26
|
+
{} :: {
|
|
27
|
+
_color: ValueObject.ValueObject<Color3>,
|
|
28
|
+
_vividness: ValueObject.ValueObject<number>,
|
|
29
|
+
Changed: Signal.Signal<Color3, Color3>,
|
|
30
|
+
},
|
|
31
|
+
{} :: typeof({ __index = ColorSwatch })
|
|
32
|
+
)) & BaseObject.BaseObject
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
self
|
|
34
|
+
function ColorSwatch.new(color: ValueObject.Mountable<Color3>, vividness: number?): ColorSwatch
|
|
35
|
+
local self: ColorSwatch = setmetatable(BaseObject.new() :: any, ColorSwatch)
|
|
28
36
|
|
|
37
|
+
self._color = self._maid:Add(ValueObject.new(Color3.new(0, 0, 0)))
|
|
29
38
|
self._vividness = self._maid:Add(ValueObject.new(nil))
|
|
30
39
|
|
|
31
40
|
self:SetBaseColor(color)
|
|
@@ -36,13 +45,16 @@ function ColorSwatch.new(color, vividness)
|
|
|
36
45
|
return self
|
|
37
46
|
end
|
|
38
47
|
|
|
39
|
-
function ColorSwatch:GetGraded(colorGrade: number)
|
|
48
|
+
function ColorSwatch:GetGraded(colorGrade: number): Color3
|
|
40
49
|
assert(type(colorGrade) == "number", "Bad colorGrade")
|
|
41
50
|
|
|
42
51
|
return ColorGradeUtils.getGradedColor(self._color.Value, colorGrade, self._vividness.Value)
|
|
43
52
|
end
|
|
44
53
|
|
|
45
|
-
function ColorSwatch:ObserveGraded(
|
|
54
|
+
function ColorSwatch:ObserveGraded(
|
|
55
|
+
colorGrade: number | Observable.Observable<number>,
|
|
56
|
+
vividness
|
|
57
|
+
): Observable.Observable<Color3>
|
|
46
58
|
assert(type(colorGrade) == "number" or Observable.isObservable(colorGrade), "Bad colorGrade")
|
|
47
59
|
|
|
48
60
|
local observeColorGrade = Blend.toPropertyObservable(colorGrade) or Rx.of(colorGrade)
|
|
@@ -55,60 +67,59 @@ function ColorSwatch:ObserveGraded(colorGrade, vividness)
|
|
|
55
67
|
end
|
|
56
68
|
|
|
57
69
|
return Rx.combineLatest({
|
|
58
|
-
colorGrade = observeColorGrade
|
|
59
|
-
vividness = observeVividness
|
|
60
|
-
baseColor = self:ObserveBaseColor()
|
|
70
|
+
colorGrade = observeColorGrade,
|
|
71
|
+
vividness = observeVividness,
|
|
72
|
+
baseColor = self:ObserveBaseColor(),
|
|
61
73
|
}):Pipe({
|
|
62
74
|
Rx.map(function(state)
|
|
63
75
|
return ColorGradeUtils.getGradedColor(state.baseColor, state.colorGrade, state.vividness)
|
|
64
|
-
end)
|
|
65
|
-
})
|
|
76
|
+
end) :: any,
|
|
77
|
+
}) :: any
|
|
66
78
|
end
|
|
67
79
|
|
|
68
|
-
function ColorSwatch:ObserveBaseColor()
|
|
80
|
+
function ColorSwatch:ObserveBaseColor(): Observable.Observable<Color3>
|
|
69
81
|
return self._color:Observe()
|
|
70
82
|
end
|
|
71
83
|
|
|
72
|
-
function ColorSwatch:ObserveVividness()
|
|
84
|
+
function ColorSwatch:ObserveVividness(): Observable.Observable<number>
|
|
73
85
|
return self._vividness:Observe()
|
|
74
86
|
end
|
|
75
87
|
|
|
76
|
-
function ColorSwatch:GetBaseColor()
|
|
88
|
+
function ColorSwatch:GetBaseColor(): Color3
|
|
77
89
|
return self._color.Value
|
|
78
90
|
end
|
|
79
91
|
|
|
80
|
-
function ColorSwatch:GetBaseGrade()
|
|
92
|
+
function ColorSwatch:GetBaseGrade(): number
|
|
81
93
|
return 100 - LuvColor3Utils.fromColor3(self._color.Value)[3]
|
|
82
94
|
end
|
|
83
95
|
|
|
84
|
-
function ColorSwatch:ObserveBaseGrade()
|
|
96
|
+
function ColorSwatch:ObserveBaseGrade(): Observable.Observable<number>
|
|
85
97
|
return self._color:Observe():Pipe({
|
|
86
98
|
Rx.map(function(color)
|
|
87
99
|
return 100 - LuvColor3Utils.fromColor3(color)[3]
|
|
88
|
-
end)
|
|
100
|
+
end),
|
|
89
101
|
})
|
|
90
102
|
end
|
|
91
103
|
|
|
92
|
-
function ColorSwatch:ObserveBaseGradeBetween(low, high)
|
|
104
|
+
function ColorSwatch:ObserveBaseGradeBetween(low: number, high: number): Observable.Observable<number>
|
|
93
105
|
return self:ObserveBaseGrade():Pipe({
|
|
94
106
|
Rx.map(function(grade)
|
|
95
107
|
return math.clamp(grade, low, high)
|
|
96
|
-
end)
|
|
108
|
+
end),
|
|
97
109
|
})
|
|
98
110
|
end
|
|
99
111
|
|
|
100
|
-
function ColorSwatch:GetVividness()
|
|
112
|
+
function ColorSwatch:GetVividness(): number
|
|
101
113
|
return self._vividness.Value
|
|
102
114
|
end
|
|
103
115
|
|
|
104
|
-
function ColorSwatch:SetVividness(vividness)
|
|
116
|
+
function ColorSwatch:SetVividness(vividness: number | Observable.Observable<number> | nil)
|
|
105
117
|
if type(vividness) == "number" then
|
|
106
118
|
self._vividness.Value = vividness
|
|
107
119
|
self._maid._currentVividness = nil
|
|
108
120
|
return
|
|
109
121
|
end
|
|
110
122
|
|
|
111
|
-
|
|
112
123
|
local observable = Blend.toPropertyObservable(vividness)
|
|
113
124
|
if not observable then
|
|
114
125
|
self._maid._currentVividness = nil
|
|
@@ -124,7 +135,7 @@ function ColorSwatch:SetVividness(vividness)
|
|
|
124
135
|
end)
|
|
125
136
|
end
|
|
126
137
|
|
|
127
|
-
function ColorSwatch:SetBaseColor(color)
|
|
138
|
+
function ColorSwatch:SetBaseColor(color: ValueObject.Mountable<Color3>)
|
|
128
139
|
if typeof(color) == "Color3" then
|
|
129
140
|
self._color.Value = color
|
|
130
141
|
self._maid._currentColor = nil
|
|
@@ -146,4 +157,4 @@ function ColorSwatch:SetBaseColor(color)
|
|
|
146
157
|
end)
|
|
147
158
|
end
|
|
148
159
|
|
|
149
|
-
return ColorSwatch
|
|
160
|
+
return ColorSwatch
|
|
@@ -2,103 +2,105 @@
|
|
|
2
2
|
@class ColorSwatch.story
|
|
3
3
|
]]
|
|
4
4
|
|
|
5
|
-
local require =
|
|
5
|
+
local require =
|
|
6
|
+
require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
|
|
6
7
|
|
|
7
|
-
local Maid = require("Maid")
|
|
8
8
|
local Blend = require("Blend")
|
|
9
9
|
local ColorSwatch = require("ColorSwatch")
|
|
10
|
+
local Maid = require("Maid")
|
|
10
11
|
|
|
11
12
|
return function(target)
|
|
12
13
|
local maid = Maid.new()
|
|
13
14
|
|
|
14
15
|
local function entry(color, text, isBaseColor)
|
|
15
16
|
return Blend.New "Frame" {
|
|
16
|
-
Name = "Entry"
|
|
17
|
-
Size = UDim2.new(0, 25, 0, 45)
|
|
18
|
-
BackgroundTransparency = 1
|
|
17
|
+
Name = "Entry",
|
|
18
|
+
Size = UDim2.new(0, 25, 0, 45),
|
|
19
|
+
BackgroundTransparency = 1,
|
|
19
20
|
|
|
20
21
|
[Blend.Children] = {
|
|
21
22
|
Blend.New "Frame" {
|
|
22
|
-
BackgroundColor3 = color
|
|
23
|
-
Size = UDim2.new(0, 25, 0, 25)
|
|
24
|
-
}
|
|
23
|
+
BackgroundColor3 = color,
|
|
24
|
+
Size = UDim2.new(0, 25, 0, 25),
|
|
25
|
+
},
|
|
25
26
|
|
|
26
27
|
Blend.New "TextLabel" {
|
|
27
|
-
Text = tostring(text)
|
|
28
|
-
Size = UDim2.new(1, 0, 0, 15)
|
|
29
|
-
Position = UDim2.new(0, 0, 1, 0)
|
|
30
|
-
AnchorPoint = Vector2.new(0, 1)
|
|
31
|
-
Font = Enum.Font.Code
|
|
32
|
-
TextScaled = true
|
|
28
|
+
Text = tostring(text),
|
|
29
|
+
Size = UDim2.new(1, 0, 0, 15),
|
|
30
|
+
Position = UDim2.new(0, 0, 1, 0),
|
|
31
|
+
AnchorPoint = Vector2.new(0, 1),
|
|
32
|
+
Font = Enum.Font.Code,
|
|
33
|
+
TextScaled = true,
|
|
33
34
|
|
|
34
35
|
[Blend.Children] = {
|
|
35
36
|
Blend.New "UIStroke" {
|
|
36
|
-
Color = Color3.new(0.6, 1, 0.6)
|
|
37
|
-
Thickness = isBaseColor and 3 or 0
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
37
|
+
Color = Color3.new(0.6, 1, 0.6),
|
|
38
|
+
Thickness = isBaseColor and 3 or 0,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}
|
|
43
44
|
end
|
|
44
45
|
|
|
45
|
-
|
|
46
46
|
local function palette(color)
|
|
47
47
|
local grades = {}
|
|
48
48
|
|
|
49
49
|
local colorSwatch = ColorSwatch.new(color, 1)
|
|
50
50
|
|
|
51
|
-
for i=0, 100, 10 do
|
|
52
|
-
table.insert(
|
|
51
|
+
for i = 0, 100, 10 do
|
|
52
|
+
table.insert(
|
|
53
|
+
grades,
|
|
54
|
+
entry(colorSwatch:GetGraded(i), tostring(i), math.abs(colorSwatch:GetBaseGrade() - i) <= 5)
|
|
55
|
+
)
|
|
53
56
|
end
|
|
54
57
|
|
|
55
58
|
return Blend.New "Frame" {
|
|
56
|
-
Size = UDim2.new(1, 0, 0, 45)
|
|
59
|
+
Size = UDim2.new(1, 0, 0, 45),
|
|
57
60
|
[Blend.Children] = {
|
|
58
|
-
grades
|
|
61
|
+
grades,
|
|
59
62
|
Blend.New "UIListLayout" {
|
|
60
|
-
Padding = UDim.new(0, 0)
|
|
61
|
-
HorizontalAlignment = Enum.HorizontalAlignment.Center
|
|
62
|
-
VerticalAlignment = Enum.VerticalAlignment.Center
|
|
63
|
-
FillDirection = Enum.FillDirection.Horizontal
|
|
64
|
-
}
|
|
65
|
-
}
|
|
63
|
+
Padding = UDim.new(0, 0),
|
|
64
|
+
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
|
65
|
+
VerticalAlignment = Enum.VerticalAlignment.Center,
|
|
66
|
+
FillDirection = Enum.FillDirection.Horizontal,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
66
69
|
}
|
|
67
70
|
end
|
|
68
71
|
|
|
69
|
-
|
|
70
72
|
maid:GiveTask((Blend.New "ScrollingFrame" {
|
|
71
|
-
Size = UDim2.new(1, 0, 1, 0)
|
|
72
|
-
Parent = target
|
|
73
|
+
Size = UDim2.new(1, 0, 1, 0),
|
|
74
|
+
Parent = target,
|
|
73
75
|
[Blend.Children] = {
|
|
74
|
-
palette(Color3.new(0, 0, 0))
|
|
76
|
+
palette(Color3.new(0, 0, 0)),
|
|
75
77
|
-- palette(Color3.new(1, 1, 1));
|
|
76
78
|
-- palette(Color3.new(0.5, 0.5, 0.5));
|
|
77
|
-
palette(Color3.fromRGB(117, 117, 117))
|
|
78
|
-
palette(Color3.fromRGB(245, 238, 214))
|
|
79
|
-
palette(Color3.fromRGB(96, 58, 58))
|
|
80
|
-
palette(Color3.fromRGB(85, 170, 127))
|
|
81
|
-
palette(Color3.new(1, 0, 0))
|
|
82
|
-
palette(Color3.new(0, 1, 0))
|
|
83
|
-
palette(Color3.new(0, 0, 1))
|
|
84
|
-
palette(Color3.new(1, 0, 1))
|
|
85
|
-
palette(Color3.new(1, 1, 0))
|
|
86
|
-
palette(Color3.new(0, 1, 1))
|
|
79
|
+
palette(Color3.fromRGB(117, 117, 117)),
|
|
80
|
+
palette(Color3.fromRGB(245, 238, 214)),
|
|
81
|
+
palette(Color3.fromRGB(96, 58, 58)),
|
|
82
|
+
palette(Color3.fromRGB(85, 170, 127)),
|
|
83
|
+
palette(Color3.new(1, 0, 0)),
|
|
84
|
+
palette(Color3.new(0, 1, 0)),
|
|
85
|
+
palette(Color3.new(0, 0, 1)),
|
|
86
|
+
palette(Color3.new(1, 0, 1)),
|
|
87
|
+
palette(Color3.new(1, 1, 0)),
|
|
88
|
+
palette(Color3.new(0, 1, 1)),
|
|
87
89
|
|
|
88
90
|
Blend.New "UIListLayout" {
|
|
89
|
-
Padding = UDim.new(0, 5)
|
|
90
|
-
HorizontalAlignment = Enum.HorizontalAlignment.Center
|
|
91
|
-
VerticalAlignment = Enum.VerticalAlignment.Top
|
|
92
|
-
FillDirection = Enum.FillDirection.Vertical
|
|
93
|
-
}
|
|
91
|
+
Padding = UDim.new(0, 5),
|
|
92
|
+
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
|
93
|
+
VerticalAlignment = Enum.VerticalAlignment.Top,
|
|
94
|
+
FillDirection = Enum.FillDirection.Vertical,
|
|
95
|
+
},
|
|
94
96
|
|
|
95
97
|
Blend.New "UIPadding" {
|
|
96
|
-
PaddingTop = UDim.new(0, 10)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
98
|
+
PaddingTop = UDim.new(0, 10),
|
|
99
|
+
},
|
|
100
|
+
},
|
|
99
101
|
}):Subscribe())
|
|
100
102
|
|
|
101
103
|
return function()
|
|
102
104
|
maid:DoCleaning()
|
|
103
105
|
end
|
|
104
|
-
end
|
|
106
|
+
end
|