@quenty/colorsequenceutils 2.1.0 → 2.1.1-canary.38bdfe3.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 +8 -0
- package/LICENSE.md +1 -1
- package/package.json +5 -2
- package/src/Shared/ColorSequenceUtils.lua +36 -0
- package/src/node_modules.project.json +7 -0
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
|
+
## [2.1.1-canary.38bdfe3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/colorsequenceutils@2.1.0...@quenty/colorsequenceutils@2.1.1-canary.38bdfe3.0) (2022-09-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/colorsequenceutils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [2.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/colorsequenceutils@2.0.1...@quenty/colorsequenceutils@2.1.0) (2022-03-27)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @quenty/colorsequenceutils
|
package/LICENSE.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/colorsequenceutils",
|
|
3
|
-
"version": "2.1.0",
|
|
3
|
+
"version": "2.1.1-canary.38bdfe3.0",
|
|
4
4
|
"description": "Utility functions for Color sequences in Roblox.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -27,5 +27,8 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@quenty/math": "2.2.0"
|
|
32
|
+
},
|
|
33
|
+
"gitHead": "38bdfe3721bddf1d272628b1104b1d8e0abaf24f"
|
|
31
34
|
}
|
|
@@ -3,10 +3,46 @@
|
|
|
3
3
|
@class ColorSequenceUtils
|
|
4
4
|
]=]
|
|
5
5
|
|
|
6
|
+
local require = require(script.Parent.loader).load(script)
|
|
7
|
+
|
|
8
|
+
local Math = require("Math")
|
|
9
|
+
|
|
6
10
|
local ColorSequenceUtils = {}
|
|
7
11
|
|
|
8
12
|
local EPSILON = 1e-3
|
|
9
13
|
|
|
14
|
+
--[=[
|
|
15
|
+
Gets the current color for the color sequence at the given timestamp.
|
|
16
|
+
|
|
17
|
+
@param colorSequence ColorSequence
|
|
18
|
+
@param t number
|
|
19
|
+
@return Color3
|
|
20
|
+
]=]
|
|
21
|
+
function ColorSequenceUtils.getColor(colorSequence: ColorSequence, t: number): Color3
|
|
22
|
+
assert(typeof(colorSequence) == "ColorSequence", "Bad colorSequence")
|
|
23
|
+
assert(type(t) == "number", "Bad t")
|
|
24
|
+
|
|
25
|
+
-- TODO: Binary search
|
|
26
|
+
local keypoints = colorSequence.Keypoints
|
|
27
|
+
|
|
28
|
+
if t <= keypoints[1].Time then
|
|
29
|
+
return keypoints[1].Value
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
for i=2, #keypoints do
|
|
33
|
+
local point = keypoints[i]
|
|
34
|
+
if point.Time < t then
|
|
35
|
+
continue
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
local prevPoint = keypoints[i-1]
|
|
39
|
+
local scale = math.clamp(Math.map(t, prevPoint.Time, point.Time, 0, 1), 0, 1)
|
|
40
|
+
return prevPoint.Value:Lerp(point.Value, scale)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
return keypoints[#keypoints].Value
|
|
44
|
+
end
|
|
45
|
+
|
|
10
46
|
--[=[
|
|
11
47
|
Makes stripes for color sequences.
|
|
12
48
|
|