@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.
@@ -2,12 +2,13 @@
2
2
  @class ColorPalette.story
3
3
  ]]
4
4
 
5
- local require = require(game:GetService("ServerScriptService"):FindFirstChild("LoaderUtils", true).Parent).bootstrapStory(script)
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
- local ColorPickerStoryUtils = require("ColorPickerStoryUtils")
10
9
  local ColorPalette = require("ColorPalette")
10
+ local ColorPickerStoryUtils = require("ColorPickerStoryUtils")
11
+ local Maid = require("Maid")
11
12
  local ValueObject = require("ValueObject")
12
13
 
13
14
  local DARK_MODE_ENABLED = true
@@ -70,174 +71,182 @@ return function(target)
70
71
  local percentMouseOver = Blend.Spring(mouseOver, 60)
71
72
 
72
73
  return Blend.New "Frame" {
73
- BackgroundColor3 = palette:ObserveColor("surface");
74
- Size = UDim2.new(0, 250, 0, 100);
74
+ BackgroundColor3 = palette:ObserveColor("surface"),
75
+ Size = UDim2.new(0, 250, 0, 100),
75
76
 
76
77
  [Blend.Children] = {
77
78
  Blend.New "TextLabel" {
78
- TextColor3 = palette:ObserveColor("text");
79
- Text = labelText;
80
- Font = Enum.Font.FredokaOne;
81
- Size = UDim2.new(1, 0, 1, 0);
82
- BackgroundTransparency = 1;
83
- TextScaled = true;
84
- ZIndex = 2;
85
- };
79
+ TextColor3 = palette:ObserveColor("text"),
80
+ Text = labelText,
81
+ Font = Enum.Font.FredokaOne,
82
+ Size = UDim2.new(1, 0, 1, 0),
83
+ BackgroundTransparency = 1,
84
+ TextScaled = true,
85
+ ZIndex = 2,
86
+ },
86
87
 
87
88
  Blend.New "UIPadding" {
88
- PaddingTop = UDim.new(0, 10);
89
- PaddingBottom = UDim.new(0, 10);
90
- PaddingLeft = UDim.new(0, 10);
91
- PaddingRight = UDim.new(0, 10);
92
- };
89
+ PaddingTop = UDim.new(0, 10),
90
+ PaddingBottom = UDim.new(0, 10),
91
+ PaddingLeft = UDim.new(0, 10),
92
+ PaddingRight = UDim.new(0, 10),
93
+ },
93
94
 
94
95
  Blend.New "UIStroke" {
95
- Color = palette:ObserveColor("surface", "border");
96
- Thickness = 5;
97
- };
96
+ Color = palette:ObserveColor("surface", "border"),
97
+ Thickness = 5,
98
+ },
98
99
 
99
100
  Blend.New "UICorner" {
100
- CornerRadius = UDim.new(0, 10);
101
- };
101
+ CornerRadius = UDim.new(0, 10),
102
+ },
102
103
 
103
104
  Blend.New "Frame" {
104
- Name = "Highlight";
105
- Size = UDim2.new(0.8, 0, 0, 20);
106
- Position = UDim2.fromScale(0.5, 0.75);
107
- AnchorPoint = Vector2.new(0.5, 0.5);
108
- BackgroundColor3 = palette:ObserveColor("accent", "highlight");
105
+ Name = "Highlight",
106
+ Size = UDim2.new(0.8, 0, 0, 20),
107
+ Position = UDim2.fromScale(0.5, 0.75),
108
+ AnchorPoint = Vector2.new(0.5, 0.5),
109
+ BackgroundColor3 = palette:ObserveColor("accent", "highlight"),
109
110
  [Blend.Children] = {
110
111
  Blend.New "UICorner" {
111
- CornerRadius = UDim.new(0, 10);
112
- };
113
- };
114
- };
112
+ CornerRadius = UDim.new(0, 10),
113
+ },
114
+ },
115
+ },
115
116
 
116
117
  Blend.New "Frame" {
117
- Name ="Button";
118
- Size = UDim2.new(0.5, 0, 0, 40);
119
- AnchorPoint = Vector2.new(1, 1);
118
+ Name = "Button",
119
+ Size = UDim2.new(0.5, 0, 0, 40),
120
+ AnchorPoint = Vector2.new(1, 1),
120
121
  BackgroundColor3 = palette:GetSwatch("action"):ObserveGraded(
121
- palette:ObserveModifiedGrade("action", "mouseOver", percentMouseOver));
122
- Position = UDim2.new(1, 30, 1, 40);
123
- ZIndex = 2;
122
+ palette:ObserveModifiedGrade("action", "mouseOver", percentMouseOver)
123
+ ),
124
+ Position = UDim2.new(1, 30, 1, 40),
125
+ ZIndex = 2,
124
126
 
125
127
  [Blend.OnEvent "MouseEnter"] = function()
126
128
  mouseOver.Value = 1
127
- end;
129
+ end,
128
130
 
129
131
  [Blend.OnEvent "MouseLeave"] = function()
130
132
  mouseOver.Value = 0
131
- end;
133
+ end,
132
134
 
133
135
  [Blend.Children] = {
134
136
  Blend.New "UICorner" {
135
- CornerRadius = UDim.new(0, 10);
136
- };
137
+ CornerRadius = UDim.new(0, 10),
138
+ },
137
139
 
138
140
  Blend.New "TextLabel" {
139
- TextColor3 = palette:ObserveColor("action", palette:ObserveModifiedGrade(
140
- palette:ObserveGradeOn("text", "action"),
141
- "mouseOver",
142
- percentMouseOver));
143
- Text = "Action";
144
- TextScaled = true;
145
- Font = Enum.Font.FredokaOne;
146
- Size = UDim2.new(1, 0, 1, 0);
147
- BackgroundTransparency = 1;
148
- ZIndex = 2;
149
- };
141
+ TextColor3 = palette:ObserveColor(
142
+ "action",
143
+ palette:ObserveModifiedGrade(
144
+ palette:ObserveGradeOn("text", "action"),
145
+ "mouseOver",
146
+ percentMouseOver
147
+ )
148
+ ),
149
+ Text = "Action",
150
+ TextScaled = true,
151
+ Font = Enum.Font.FredokaOne,
152
+ Size = UDim2.new(1, 0, 1, 0),
153
+ BackgroundTransparency = 1,
154
+ ZIndex = 2,
155
+ },
150
156
 
151
157
  [Blend.Children] = {
152
158
  Blend.New "UIStroke" {
153
- Color = palette:ObserveColor("action", palette:ObserveModifiedGrade(
154
- palette:ObserveGradeOn("border", "action"),
155
- "mouseOver",
156
- percentMouseOver));
157
- Thickness = 5;
158
- };
159
- };
159
+ Color = palette:ObserveColor(
160
+ "action",
161
+ palette:ObserveModifiedGrade(
162
+ palette:ObserveGradeOn("border", "action"),
163
+ "mouseOver",
164
+ percentMouseOver
165
+ )
166
+ ),
167
+ Thickness = 5,
168
+ },
169
+ },
160
170
 
161
171
  Blend.New "Frame" {
162
- Name = "Highlight";
163
- Size = UDim2.new(0.9, 0, 0, 10);
164
- Position = UDim2.fromScale(0.5, 0.75);
165
- AnchorPoint = Vector2.new(0.5, 0.5);
166
- BackgroundColor3 = palette:ObserveColor("accent", palette:ObserveGradeOn("highlight", "action"));
172
+ Name = "Highlight",
173
+ Size = UDim2.new(0.9, 0, 0, 10),
174
+ Position = UDim2.fromScale(0.5, 0.75),
175
+ AnchorPoint = Vector2.new(0.5, 0.5),
176
+ BackgroundColor3 = palette:ObserveColor(
177
+ "accent",
178
+ palette:ObserveGradeOn("highlight", "action")
179
+ ),
167
180
  [Blend.Children] = {
168
181
  Blend.New "UICorner" {
169
- CornerRadius = UDim.new(0, 10);
170
- };
171
- };
172
- };
173
-
182
+ CornerRadius = UDim.new(0, 10),
183
+ },
184
+ },
185
+ },
174
186
 
175
187
  Blend.New "UIPadding" {
176
- PaddingTop = UDim.new(0, 5);
177
- PaddingBottom = UDim.new(0, 5);
178
- PaddingLeft = UDim.new(0, 5);
179
- PaddingRight = UDim.new(0, 5);
180
- };
181
- };
182
- };
183
- };
184
- };
188
+ PaddingTop = UDim.new(0, 5),
189
+ PaddingBottom = UDim.new(0, 5),
190
+ PaddingLeft = UDim.new(0, 5),
191
+ PaddingRight = UDim.new(0, 5),
192
+ },
193
+ },
194
+ },
195
+ },
196
+ }
185
197
  end
186
198
 
187
-
188
199
  maid:GiveTask((Blend.New "ScrollingFrame" {
189
- Size = UDim2.new(1, 0, 1, 0);
190
- BackgroundColor3 = Color3.new(0, 0, 0);
191
- AutomaticCanvasSize = Enum.AutomaticSize.Y;
192
- CanvasSize = UDim2.new(1, 0, 0, 0);
193
- Parent = target;
200
+ Size = UDim2.new(1, 0, 1, 0),
201
+ BackgroundColor3 = Color3.new(0, 0, 0),
202
+ AutomaticCanvasSize = Enum.AutomaticSize.Y,
203
+ CanvasSize = UDim2.new(1, 0, 0, 0),
204
+ Parent = target,
194
205
  [Blend.Children] = {
195
206
  ColorPickerStoryUtils.create(maid, function(createPicker)
196
- createPicker("Surface", palette:GetColorValue("surface"));
197
- createPicker("Text", palette:GetColorValue("text"));
198
- createPicker("Accent", palette:GetColorValue("accent"));
199
- createPicker("Action", palette:GetColorValue("action"));
200
- end);
207
+ createPicker("Surface", palette:GetColorValue("surface"))
208
+ createPicker("Text", palette:GetColorValue("text"))
209
+ createPicker("Accent", palette:GetColorValue("accent"))
210
+ createPicker("Action", palette:GetColorValue("action"))
211
+ end),
201
212
 
202
213
  Blend.New "Frame" {
203
- Size = UDim2.new(1, 0, 0, 0);
204
- BackgroundTransparency = 1;
205
- AutomaticSize = Enum.AutomaticSize.Y;
214
+ Size = UDim2.new(1, 0, 0, 0),
215
+ BackgroundTransparency = 1,
216
+ AutomaticSize = Enum.AutomaticSize.Y,
206
217
 
207
218
  [Blend.Children] = {
208
- sampleGui("Light");
219
+ sampleGui("Light"),
209
220
 
210
221
  Blend.New "UIListLayout" {
211
- Padding = UDim.new(0, 50);
212
- HorizontalAlignment = Enum.HorizontalAlignment.Center;
213
- VerticalAlignment = Enum.VerticalAlignment.Top;
214
- FillDirection = Enum.FillDirection.Vertical;
215
- };
216
- };
217
- };
218
-
222
+ Padding = UDim.new(0, 50),
223
+ HorizontalAlignment = Enum.HorizontalAlignment.Center,
224
+ VerticalAlignment = Enum.VerticalAlignment.Top,
225
+ FillDirection = Enum.FillDirection.Vertical,
226
+ },
227
+ },
228
+ },
219
229
 
220
230
  Blend.New "UIListLayout" {
221
- Padding = UDim.new(0, 20);
222
- HorizontalAlignment = Enum.HorizontalAlignment.Center;
223
- VerticalAlignment = Enum.VerticalAlignment.Top;
224
- FillDirection = Enum.FillDirection.Vertical;
225
- };
231
+ Padding = UDim.new(0, 20),
232
+ HorizontalAlignment = Enum.HorizontalAlignment.Center,
233
+ VerticalAlignment = Enum.VerticalAlignment.Top,
234
+ FillDirection = Enum.FillDirection.Vertical,
235
+ },
226
236
 
227
237
  Blend.New "UIPadding" {
228
- PaddingTop = UDim.new(0, 10);
229
- };
238
+ PaddingTop = UDim.new(0, 10),
239
+ },
230
240
 
231
241
  Blend.New "Frame" {
232
- Name = "TestCustomColor";
233
- Size = UDim2.new(0, 30, 0, 30);
234
- BackgroundColor3 = palette:ObserveColor(Color3.new(0, 0, 1), "text");
235
- };
236
- }
242
+ Name = "TestCustomColor",
243
+ Size = UDim2.new(0, 30, 0, 30),
244
+ BackgroundColor3 = palette:ObserveColor(Color3.new(0, 0, 1), "text"),
245
+ },
246
+ },
237
247
  }):Subscribe())
238
248
 
239
-
240
249
  return function()
241
250
  maid:DoCleaning()
242
251
  end
243
- end
252
+ end
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Holds fonts for reuse by giving fonts a semantic name. This makes theming easier in general.
3
4
 
@@ -7,22 +8,34 @@
7
8
  local require = require(script.Parent.loader).load(script)
8
9
 
9
10
  local BaseObject = require("BaseObject")
11
+ local Observable = require("Observable")
12
+ local ObservableSet = require("ObservableSet")
10
13
  local Rx = require("Rx")
14
+ local Signal = require("Signal")
11
15
  local ValueObject = require("ValueObject")
12
- local ObservableSet = require("ObservableSet")
13
- local _Observable = require("Observable")
14
16
 
15
17
  local FontPalette = setmetatable({}, BaseObject)
16
18
  FontPalette.ClassName = "FontPalette"
17
19
  FontPalette.__index = FontPalette
18
20
 
21
+ export type FontPalette = typeof(setmetatable(
22
+ {} :: {
23
+ FontAdded: Signal.Signal<string>,
24
+ _fontKeys: ObservableSet.ObservableSet<string>,
25
+ _fonts: { [string]: ValueObject.ValueObject<Enum.Font> },
26
+ _fontFaces: { [string]: ValueObject.ValueObject<Font> },
27
+ _defaultFontMap: { [string]: Enum.Font | Font },
28
+ },
29
+ {} :: typeof({ __index = FontPalette })
30
+ )) & BaseObject.BaseObject
31
+
19
32
  --[=[
20
33
  Constructs a new font palette.
21
34
 
22
35
  @return FontPallete
23
36
  ]=]
24
- function FontPalette.new()
25
- local self = setmetatable(BaseObject.new(), FontPalette)
37
+ function FontPalette.new(): FontPalette
38
+ local self: FontPalette = setmetatable(BaseObject.new() :: any, FontPalette)
26
39
 
27
40
  self._fonts = {}
28
41
  self._fontFaces = {}
@@ -40,7 +53,7 @@ end
40
53
 
41
54
  @return { string }
42
55
  ]=]
43
- function FontPalette:GetFontNames(): { string }
56
+ function FontPalette.GetFontNames(self: FontPalette): { string }
44
57
  return self._fontKeys:GetList()
45
58
  end
46
59
 
@@ -49,8 +62,8 @@ end
49
62
  existing fonts.
50
63
  @return Observable<string>
51
64
  ]=]
52
- function FontPalette:ObserveFontNames()
53
- return Rx.fromSignal(self.FontAdded):Pipe({
65
+ function FontPalette.ObserveFontNames(self: FontPalette): Observable.Observable<string>
66
+ return Rx.fromSignal(self.FontAdded :: any):Pipe({
54
67
  Rx.startFrom(function()
55
68
  if self.Destroy then
56
69
  return self:GetFontNames()
@@ -58,8 +71,8 @@ function FontPalette:ObserveFontNames()
58
71
  warn("[FontPalette.ObserveFontNames] - Calling when FontPalette is already dead")
59
72
  return {}
60
73
  end
61
- end),
62
- })
74
+ end) :: any,
75
+ }) :: any
63
76
  end
64
77
 
65
78
  --[=[
@@ -68,7 +81,7 @@ end
68
81
 
69
82
  @return Observable<Brio<string>>
70
83
  ]=]
71
- function FontPalette:ObserveFontNamesBrio()
84
+ function FontPalette.ObserveFontNamesBrio(self: FontPalette)
72
85
  return self._fontKeys:ObserveItemsBrio()
73
86
  end
74
87
 
@@ -78,7 +91,7 @@ end
78
91
  @param fontName string
79
92
  @return Enum.Font
80
93
  ]=]
81
- function FontPalette:GetFont(fontName: string): Enum.Font
94
+ function FontPalette.GetFont(self: FontPalette, fontName: string): Enum.Font
82
95
  assert(type(fontName) == "string", "Bad fontName")
83
96
 
84
97
  return self:GetFontValue(fontName).Value
@@ -90,7 +103,7 @@ end
90
103
  @param fontName string
91
104
  @return Observe<Enum.Font>
92
105
  ]=]
93
- function FontPalette:ObserveFont(fontName: string): _Observable.Observable<Enum.Font>
106
+ function FontPalette.ObserveFont(self: FontPalette, fontName: string): Observable.Observable<Enum.Font>
94
107
  assert(type(fontName) == "string", "Bad fontName")
95
108
 
96
109
  return self:GetFontValue(fontName):Observe()
@@ -104,10 +117,11 @@ end
104
117
  @param style (FontStyle | Observable<FontStyle>)?
105
118
  @return Observable<Font>
106
119
  ]=]
107
- function FontPalette:ObserveFontFace(
120
+ function FontPalette.ObserveFontFace(
121
+ self: FontPalette,
108
122
  fontName: string,
109
- weight: (Enum.FontWeight | _Observable.Observable<Enum.FontWeight>)?,
110
- style: (Enum.FontStyle | _Observable.Observable<Enum.FontWeight>)?
123
+ weight: (Enum.FontWeight | Observable.Observable<Enum.FontWeight>)?,
124
+ style: (Enum.FontStyle | Observable.Observable<Enum.FontWeight>)?
111
125
  )
112
126
  assert(type(fontName) == "string", "Bad fontName")
113
127
 
@@ -122,7 +136,7 @@ function FontPalette:ObserveFontFace(
122
136
  }):Pipe({
123
137
  Rx.map(function(state)
124
138
  return Font.new(state.font.Family, state.weight or state.font.Weight, state.style or state.font.Style)
125
- end),
139
+ end) :: any,
126
140
  })
127
141
  end
128
142
 
@@ -132,7 +146,7 @@ end
132
146
  @param fontName string
133
147
  @return ValueObject<Font>
134
148
  ]=]
135
- function FontPalette:GetFontFaceValue(fontName: string): Font
149
+ function FontPalette.GetFontFaceValue(self: FontPalette, fontName: string): ValueObject.ValueObject<Font>
136
150
  assert(type(fontName) == "string", "Bad fontName")
137
151
 
138
152
  local fontValue = self._fontFaces[fontName]
@@ -149,7 +163,7 @@ end
149
163
  @param fontName string
150
164
  @return ValueObject<Font>
151
165
  ]=]
152
- function FontPalette:GetFontValue(fontName: string): ValueObject.ValueObject<Enum.Font>
166
+ function FontPalette.GetFontValue(self: FontPalette, fontName: string): ValueObject.ValueObject<Enum.Font>
153
167
  assert(type(fontName) == "string", "Bad fontName")
154
168
 
155
169
  local fontValue = self._fonts[fontName]
@@ -162,9 +176,9 @@ end
162
176
 
163
177
  --[=[
164
178
  Gets the default font map
165
- @return { string: Font }
179
+ @return { string: Font | Enum.Font }
166
180
  ]=]
167
- function FontPalette:GetDefaultFontMap(): { string: Font }
181
+ function FontPalette.GetDefaultFontMap(self: FontPalette): { [string]: Font | Enum.Font }
168
182
  return self._defaultFontMap
169
183
  end
170
184
 
@@ -173,9 +187,13 @@ end
173
187
 
174
188
  @param fontName string
175
189
  @param defaultFont Enum.Font | Font
176
- @return ValueObject<Enum.Font | Font>
190
+ @return ValueObject<Enum.Font>
177
191
  ]=]
178
- function FontPalette:DefineFont(fontName: string, defaultFont: Enum.Font | Font): ValueObject.ValueObject<Enum.Font | Font>?
192
+ function FontPalette.DefineFont(
193
+ self: FontPalette,
194
+ fontName: string,
195
+ defaultFont: Enum.Font | Font
196
+ ): ValueObject.ValueObject<Enum.Font>?
179
197
  assert(type(fontName) == "string", "Bad fontName")
180
198
  assert(typeof(defaultFont) == "EnumItem" or typeof(defaultFont) == "Font", "Bad defaultFont")
181
199
 
@@ -184,19 +202,20 @@ function FontPalette:DefineFont(fontName: string, defaultFont: Enum.Font | Font)
184
202
  return nil
185
203
  end
186
204
 
187
- local defaultFontEnum
188
- local defaultFontFace
205
+ local defaultFontEnum: any -- : Enum.Font
206
+ local defaultFontFace: Font
189
207
  if typeof(defaultFont) == "EnumItem" then
190
208
  defaultFontEnum = defaultFont
191
209
  defaultFontFace = Font.fromEnum(defaultFont)
192
210
  elseif typeof(defaultFont) == "Font" then
211
+ -- TODO: Fix this
193
212
  defaultFontEnum = defaultFont
194
213
  defaultFontFace = defaultFont
195
214
  else
196
215
  error("Bad defaultFont")
197
216
  end
198
217
 
199
- local fontValue = self._maid:Add(ValueObject.new(defaultFontEnum))
218
+ local fontValue: ValueObject.ValueObject<Enum.Font> = self._maid:Add(ValueObject.new(defaultFontEnum))
200
219
  local fontFaceValue = self._maid:Add(ValueObject.new(defaultFontFace))
201
220
 
202
221
  self._fonts[fontName] = fontValue
@@ -221,12 +240,12 @@ function FontPalette:DefineFont(fontName: string, defaultFont: Enum.Font | Font)
221
240
  return fontValue
222
241
  end
223
242
 
224
- function FontPalette:_tryToGetFontFace(fontFace: Font)
243
+ function FontPalette._tryToGetFontFace(_self: FontPalette, fontFace: Font)
225
244
  local assetName = string.gmatch(fontFace.Family, "rbxasset://fonts/families/([%w]+).json$")()
226
245
 
227
246
  local fontEnum
228
247
  pcall(function()
229
- fontEnum = Enum.Font[assetName]
248
+ fontEnum = (Enum.Font :: any)[assetName]
230
249
  end)
231
250
 
232
251
  if fontEnum then
@@ -236,4 +255,4 @@ function FontPalette:_tryToGetFontFace(fontFace: Font)
236
255
  end
237
256
  end
238
257
 
239
- return FontPalette
258
+ return FontPalette
@@ -5,18 +5,27 @@
5
5
  local require = require(script.Parent.loader).load(script)
6
6
 
7
7
  local BaseObject = require("BaseObject")
8
- local Rx = require("Rx")
9
8
  local Blend = require("Blend")
9
+ local ColorGradeUtils = require("ColorGradeUtils")
10
10
  local Observable = require("Observable")
11
+ local Rx = require("Rx")
11
12
  local ValueObject = require("ValueObject")
12
- local ColorGradeUtils = require("ColorGradeUtils")
13
13
 
14
14
  local ColorGradePalette = setmetatable({}, BaseObject)
15
15
  ColorGradePalette.ClassName = "ColorGradePalette"
16
16
  ColorGradePalette.__index = ColorGradePalette
17
17
 
18
- function ColorGradePalette.new()
19
- local self = setmetatable(BaseObject.new(), ColorGradePalette)
18
+ export type ColorGradePalette = typeof(setmetatable(
19
+ {} :: {
20
+ _grades: { [string]: Observable.Observable<number> },
21
+ _vividness: { [string]: Observable.Observable<number> },
22
+ _defaultSurfaceName: ValueObject.ValueObject<string>,
23
+ },
24
+ {} :: typeof({ __index = ColorGradePalette })
25
+ )) & BaseObject.BaseObject
26
+
27
+ function ColorGradePalette.new(): ColorGradePalette
28
+ local self: ColorGradePalette = setmetatable(BaseObject.new() :: any, ColorGradePalette)
20
29
 
21
30
  self._grades = {}
22
31
  self._vividness = {}
@@ -33,7 +42,7 @@ function ColorGradePalette:SetDefaultSurfaceName(gradeName: string)
33
42
  self._defaultSurfaceName.Value = gradeName
34
43
  end
35
44
 
36
- function ColorGradePalette:HasGrade(gradeName)
45
+ function ColorGradePalette:HasGrade(gradeName: string): boolean
37
46
  if self._grades[gradeName] then
38
47
  return true
39
48
  else
@@ -87,7 +96,7 @@ function ColorGradePalette:GetVividness(gradeName: string)
87
96
  return vividness
88
97
  end
89
98
 
90
- function ColorGradePalette:Add(gradeName, colorGrade, vividness)
99
+ function ColorGradePalette:Add(gradeName: string, colorGrade, vividness)
91
100
  assert(type(gradeName) == "string", "Bad gradeName")
92
101
 
93
102
  self._grades[gradeName] = Blend.toPropertyObservable(colorGrade) or Rx.of(colorGrade)
@@ -107,18 +116,17 @@ end
107
116
 
108
117
  function ColorGradePalette:ObserveModified(gradeName, amount, multiplier)
109
118
  return Rx.combineLatest({
110
- grade = self:_observeGradeFromName(gradeName);
111
- amount = self:_observeGradeFromName(amount);
112
- multiplier = multiplier or 1;
119
+ grade = self:_observeGradeFromName(gradeName),
120
+ amount = self:_observeGradeFromName(amount),
121
+ multiplier = multiplier or 1,
113
122
  }):Pipe({
114
123
  Rx.map(function(state)
115
124
  assert(type(state.grade) == "number", "Bad state.grade")
116
125
  assert(type(state.amount) == "number", "Bad state.amount")
117
126
  assert(type(state.multiplier) == "number", "Bad state.multiplier")
118
127
 
119
-
120
- return state.grade + state.multiplier*state.amount
121
- end);
128
+ return state.grade + state.multiplier * state.amount
129
+ end),
122
130
  })
123
131
  end
124
132
 
@@ -132,9 +140,9 @@ function ColorGradePalette:ObserveOn(gradeName, newSurfaceName, baseSurfaceName)
132
140
  end
133
141
 
134
142
  return Rx.combineLatest({
135
- grade = self:_observeGradeFromName(gradeName);
136
- newSurfaceGrade = self:_observeGradeFromName(newSurfaceName);
137
- baseSurfaceGrade = observeBaseSurfaceGrade;
143
+ grade = self:_observeGradeFromName(gradeName),
144
+ newSurfaceGrade = self:_observeGradeFromName(newSurfaceName),
145
+ baseSurfaceGrade = observeBaseSurfaceGrade,
138
146
  }):Pipe({
139
147
  Rx.map(function(state)
140
148
  local difference = state.grade - state.baseSurfaceGrade
@@ -153,8 +161,9 @@ function ColorGradePalette:ObserveOn(gradeName, newSurfaceName, baseSurfaceName)
153
161
  end
154
162
 
155
163
  return finalGrade
156
- end)
157
- }), self._vividness[gradeName]
164
+ end),
165
+ }),
166
+ self._vividness[gradeName]
158
167
  end
159
168
 
160
169
  function ColorGradePalette:_observeGradeFromName(gradeName)
@@ -172,7 +181,7 @@ function ColorGradePalette:_observeGradeFromName(gradeName)
172
181
  else
173
182
  error("Bad grade value")
174
183
  end
175
- end)
184
+ end),
176
185
  })
177
186
  end
178
187
 
@@ -185,7 +194,7 @@ function ColorGradePalette:_observeGradeFromName(gradeName)
185
194
  local colorOrObservable = Blend.toPropertyObservable(gradeName)
186
195
  if colorOrObservable then
187
196
  return colorOrObservable:Pipe({
188
- Rx.map(ColorGradeUtils.getGrade)
197
+ Rx.map(ColorGradeUtils.getGrade),
189
198
  })
190
199
  end
191
200
 
@@ -200,8 +209,8 @@ function ColorGradePalette:ObserveDefaultSurfaceGrade()
200
209
  else
201
210
  return Rx.EMPTY
202
211
  end
203
- end)
212
+ end),
204
213
  })
205
214
  end
206
215
 
207
- return ColorGradePalette
216
+ return ColorGradePalette