@quenty/colorsequenceutils 7.8.1 → 7.8.2
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 +11 -0
- package/package.json +4 -4
- package/src/Shared/ColorSequenceUtils.lua +15 -14
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
## [7.8.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/colorsequenceutils@7.8.1...@quenty/colorsequenceutils@7.8.2) (2025-04-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [7.8.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/colorsequenceutils@7.8.0...@quenty/colorsequenceutils@7.8.1) (2025-03-21)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/colorsequenceutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/colorsequenceutils",
|
|
3
|
-
"version": "7.8.
|
|
3
|
+
"version": "7.8.2",
|
|
4
4
|
"description": "Utility functions for Color sequences in Roblox.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/loader": "^10.8.
|
|
32
|
-
"@quenty/math": "^2.7.
|
|
31
|
+
"@quenty/loader": "^10.8.1",
|
|
32
|
+
"@quenty/math": "^2.7.2"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
|
|
35
35
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Utility functions for Color sequences in Roblox.
|
|
3
4
|
@class ColorSequenceUtils
|
|
@@ -29,13 +30,13 @@ function ColorSequenceUtils.getColor(colorSequence: ColorSequence, t: number): C
|
|
|
29
30
|
return keypoints[1].Value
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
for i=2, #keypoints do
|
|
33
|
+
for i = 2, #keypoints do
|
|
33
34
|
local point = keypoints[i]
|
|
34
35
|
if point.Time < t then
|
|
35
36
|
continue
|
|
36
37
|
end
|
|
37
38
|
|
|
38
|
-
local prevPoint = keypoints[i-1]
|
|
39
|
+
local prevPoint = keypoints[i - 1]
|
|
39
40
|
local scale = math.clamp(Math.map(t, prevPoint.Time, point.Time, 0, 1), 0, 1)
|
|
40
41
|
return prevPoint.Value:Lerp(point.Value, scale)
|
|
41
42
|
end
|
|
@@ -53,7 +54,7 @@ end
|
|
|
53
54
|
@param percentOffset number
|
|
54
55
|
@return ColorSequence
|
|
55
56
|
]=]
|
|
56
|
-
function ColorSequenceUtils.stripe(stripes, backgroundColor3, stripeColor3, percentStripeThickness, percentOffset)
|
|
57
|
+
function ColorSequenceUtils.stripe(stripes: number, backgroundColor3: Color3, stripeColor3: Color3, percentStripeThickness: number, percentOffset: number): ColorSequence
|
|
57
58
|
percentOffset = percentOffset or 0
|
|
58
59
|
percentStripeThickness = math.clamp(percentStripeThickness or 0.5, 0, 1)
|
|
59
60
|
|
|
@@ -63,16 +64,16 @@ function ColorSequenceUtils.stripe(stripes, backgroundColor3, stripeColor3, perc
|
|
|
63
64
|
return ColorSequence.new(stripeColor3)
|
|
64
65
|
end
|
|
65
66
|
|
|
66
|
-
local timeWidth = 1/stripes
|
|
67
|
-
local timeOffset = percentOffset*timeWidth
|
|
68
|
-
timeOffset = timeOffset + percentStripeThickness*timeWidth*0.5 -- We add thickness to center
|
|
67
|
+
local timeWidth = 1 / stripes
|
|
68
|
+
local timeOffset = percentOffset * timeWidth
|
|
69
|
+
timeOffset = timeOffset + percentStripeThickness * timeWidth * 0.5 -- We add thickness to center
|
|
69
70
|
timeOffset = timeOffset % timeWidth
|
|
70
71
|
|
|
71
72
|
-- Generate initialial points
|
|
72
|
-
local waypoints = {}
|
|
73
|
-
for i=0, stripes-1 do
|
|
74
|
-
local timestampStart = (i/stripes + timeOffset) % 1
|
|
75
|
-
local timeStampMiddle = (timestampStart + timeWidth*(1 - percentStripeThickness)) % 1
|
|
73
|
+
local waypoints: { ColorSequenceKeypoint } = {}
|
|
74
|
+
for i = 0, stripes - 1 do
|
|
75
|
+
local timestampStart = (i / stripes + timeOffset) % 1
|
|
76
|
+
local timeStampMiddle = (timestampStart + timeWidth * (1 - percentStripeThickness)) % 1
|
|
76
77
|
|
|
77
78
|
table.insert(waypoints, ColorSequenceKeypoint.new(timestampStart, backgroundColor3))
|
|
78
79
|
table.insert(waypoints, ColorSequenceKeypoint.new(timeStampMiddle, stripeColor3))
|
|
@@ -82,13 +83,13 @@ function ColorSequenceUtils.stripe(stripes, backgroundColor3, stripeColor3, perc
|
|
|
82
83
|
return a.Time < b.Time
|
|
83
84
|
end)
|
|
84
85
|
|
|
85
|
-
local fullWaypoints = {}
|
|
86
|
+
local fullWaypoints: { ColorSequenceKeypoint } = {}
|
|
86
87
|
|
|
87
88
|
-- Handle first!
|
|
88
89
|
table.insert(fullWaypoints, waypoints[1])
|
|
89
90
|
|
|
90
|
-
for i=2, #waypoints do
|
|
91
|
-
local previous = waypoints[i-1]
|
|
91
|
+
for i = 2, #waypoints do
|
|
92
|
+
local previous = waypoints[i - 1]
|
|
92
93
|
local current = waypoints[i]
|
|
93
94
|
|
|
94
95
|
if current.Time - EPSILON > previous.Time then
|
|
@@ -101,7 +102,7 @@ function ColorSequenceUtils.stripe(stripes, backgroundColor3, stripeColor3, perc
|
|
|
101
102
|
-- Add beginning
|
|
102
103
|
local first = fullWaypoints[1]
|
|
103
104
|
if first.Time >= EPSILON then
|
|
104
|
-
local color
|
|
105
|
+
local color: Color3
|
|
105
106
|
if first.Value == backgroundColor3 then
|
|
106
107
|
color = stripeColor3
|
|
107
108
|
elseif first.Value == stripeColor3 then
|