roblox-opencode 1.0.0 → 1.0.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/README.md +112 -122
- package/commands/setup-game.md +108 -108
- package/commands/sync-check.md +53 -53
- package/core/roblox-core.md +93 -93
- package/dist/server.js +189 -167
- package/package.json +35 -35
- package/skills/roblox-analytics/SKILL.md +277 -277
- package/skills/roblox-analytics/references/event-batcher.luau +75 -75
- package/skills/roblox-animation-vfx/SKILL.md +1325 -1325
- package/skills/roblox-architecture/SKILL.md +877 -863
- package/skills/roblox-architecture/references/combat-systems.md +1381 -1381
- package/skills/roblox-code-review/SKILL.md +686 -686
- package/skills/roblox-data/SKILL.md +889 -889
- package/skills/roblox-data/references/inventory-systems.md +1729 -1729
- package/skills/roblox-debug/SKILL.md +98 -98
- package/skills/roblox-gui/SKILL.md +1103 -1103
- package/skills/roblox-gui-fusion/SKILL.md +150 -150
- package/skills/roblox-gui-fusion/references/inventory.luau +427 -427
- package/skills/roblox-gui-fusion/references/settings-menu.luau +579 -579
- package/skills/roblox-gui-fusion/references/shop.luau +411 -411
- package/skills/roblox-luau-mastery/SKILL.md +1618 -1519
- package/skills/roblox-monetization/SKILL.md +1084 -1084
- package/skills/roblox-monetization/references/process-receipt.luau +131 -131
- package/skills/roblox-networking/SKILL.md +669 -669
- package/skills/roblox-networking/references/remote-validator.luau +193 -193
- package/skills/roblox-publish-checklist/SKILL.md +127 -127
- package/skills/roblox-runtime/SKILL.md +753 -753
- package/skills/roblox-sharp-edges/SKILL.md +294 -294
- package/skills/roblox-sync/SKILL.md +126 -126
- package/skills/roblox-testing/SKILL.md +943 -943
- package/skills/roblox-tooling/SKILL.md +149 -149
- package/vendor/LICENSES/ProfileStore-LICENSE +201 -201
- package/vendor/LICENSES/RbxUtil-LICENSE +7 -7
- package/vendor/LICENSES/promise-LICENSE +20 -20
- package/vendor/LICENSES/t-LICENSE +21 -21
- package/vendor/LICENSES/testez-LICENSE +200 -200
- package/vendor/README.md +83 -83
- package/vendor/fusion/Animation/ExternalTime.luau +83 -83
- package/vendor/fusion/Animation/Spring.luau +321 -321
- package/vendor/fusion/Animation/Stopwatch.luau +127 -127
- package/vendor/fusion/Animation/Tween.luau +187 -187
- package/vendor/fusion/Animation/getTweenDuration.luau +27 -27
- package/vendor/fusion/Animation/getTweenRatio.luau +47 -47
- package/vendor/fusion/Animation/lerpType.luau +163 -163
- package/vendor/fusion/Animation/packType.luau +99 -99
- package/vendor/fusion/Animation/springCoefficients.luau +80 -80
- package/vendor/fusion/Animation/unpackType.luau +102 -102
- package/vendor/fusion/Colour/Oklab.luau +70 -70
- package/vendor/fusion/Colour/sRGB.luau +54 -54
- package/vendor/fusion/External.luau +167 -167
- package/vendor/fusion/ExternalDebug.luau +69 -69
- package/vendor/fusion/Graph/Observer.luau +113 -113
- package/vendor/fusion/Graph/castToGraph.luau +28 -28
- package/vendor/fusion/Graph/change.luau +80 -80
- package/vendor/fusion/Graph/depend.luau +32 -32
- package/vendor/fusion/Graph/evaluate.luau +55 -55
- package/vendor/fusion/Instances/Attribute.luau +57 -57
- package/vendor/fusion/Instances/AttributeChange.luau +46 -46
- package/vendor/fusion/Instances/AttributeOut.luau +63 -63
- package/vendor/fusion/Instances/Child.luau +21 -21
- package/vendor/fusion/Instances/Children.luau +147 -147
- package/vendor/fusion/Instances/Hydrate.luau +32 -32
- package/vendor/fusion/Instances/New.luau +52 -52
- package/vendor/fusion/Instances/OnChange.luau +49 -49
- package/vendor/fusion/Instances/OnEvent.luau +53 -53
- package/vendor/fusion/Instances/Out.luau +69 -69
- package/vendor/fusion/Instances/applyInstanceProps.luau +148 -148
- package/vendor/fusion/Instances/defaultProps.luau +194 -194
- package/vendor/fusion/LICENSE +21 -21
- package/vendor/fusion/Logging/formatError.luau +48 -48
- package/vendor/fusion/Logging/messages.luau +51 -51
- package/vendor/fusion/Logging/parseError.luau +24 -24
- package/vendor/fusion/Memory/checkLifetime.luau +133 -133
- package/vendor/fusion/Memory/deriveScope.luau +23 -23
- package/vendor/fusion/Memory/deriveScopeImpl.luau +44 -44
- package/vendor/fusion/Memory/doCleanup.luau +78 -78
- package/vendor/fusion/Memory/innerScope.luau +33 -33
- package/vendor/fusion/Memory/legacyCleanup.luau +17 -17
- package/vendor/fusion/Memory/needsDestruction.luau +16 -16
- package/vendor/fusion/Memory/poisonScope.luau +33 -33
- package/vendor/fusion/Memory/scopePool.luau +54 -54
- package/vendor/fusion/Memory/scoped.luau +26 -26
- package/vendor/fusion/Memory/whichLivesLonger.luau +74 -74
- package/vendor/fusion/RobloxExternal.luau +97 -97
- package/vendor/fusion/State/Computed.luau +138 -138
- package/vendor/fusion/State/For/Disassembly.luau +210 -210
- package/vendor/fusion/State/For/ForTypes.luau +30 -30
- package/vendor/fusion/State/For/init.luau +109 -109
- package/vendor/fusion/State/ForKeys.luau +93 -93
- package/vendor/fusion/State/ForPairs.luau +96 -96
- package/vendor/fusion/State/ForValues.luau +93 -93
- package/vendor/fusion/State/Value.luau +87 -87
- package/vendor/fusion/State/castToState.luau +25 -25
- package/vendor/fusion/State/peek.luau +30 -30
- package/vendor/fusion/Types.luau +314 -314
- package/vendor/fusion/Utility/Contextual.luau +90 -90
- package/vendor/fusion/Utility/Safe.luau +22 -22
- package/vendor/fusion/Utility/isSimilar.luau +29 -29
- package/vendor/fusion/Utility/merge.luau +35 -35
- package/vendor/fusion/Utility/nameOf.luau +34 -34
- package/vendor/fusion/Utility/never.luau +13 -13
- package/vendor/fusion/Utility/nicknames.luau +10 -10
- package/vendor/fusion/Utility/xtypeof.luau +26 -26
- package/vendor/fusion/init.luau +82 -82
- package/vendor/profilestore/init.luau +2242 -2242
- package/vendor/promise/init.luau +1982 -1982
- package/vendor/rbxutil/buffer-util/Buffer.test.luau +25 -25
- package/vendor/rbxutil/buffer-util/BufferReader.luau +228 -228
- package/vendor/rbxutil/buffer-util/BufferWriter.luau +269 -269
- package/vendor/rbxutil/buffer-util/DataTypeBuffer.luau +223 -223
- package/vendor/rbxutil/buffer-util/Types.luau +60 -60
- package/vendor/rbxutil/buffer-util/index.d.ts +153 -153
- package/vendor/rbxutil/buffer-util/init.luau +41 -41
- package/vendor/rbxutil/buffer-util/package.json +16 -16
- package/vendor/rbxutil/buffer-util/wally.toml +9 -9
- package/vendor/rbxutil/comm/Client/ClientComm.luau +232 -232
- package/vendor/rbxutil/comm/Client/ClientRemoteProperty.luau +156 -156
- package/vendor/rbxutil/comm/Client/ClientRemoteSignal.luau +109 -109
- package/vendor/rbxutil/comm/Client/init.luau +135 -135
- package/vendor/rbxutil/comm/Server/RemoteProperty.luau +295 -295
- package/vendor/rbxutil/comm/Server/RemoteSignal.luau +211 -211
- package/vendor/rbxutil/comm/Server/ServerComm.luau +211 -211
- package/vendor/rbxutil/comm/Server/init.luau +140 -140
- package/vendor/rbxutil/comm/Types.luau +18 -18
- package/vendor/rbxutil/comm/Util.luau +27 -27
- package/vendor/rbxutil/comm/init.luau +35 -35
- package/vendor/rbxutil/comm/wally.toml +13 -13
- package/vendor/rbxutil/component/init.luau +759 -759
- package/vendor/rbxutil/component/init.test.luau +311 -311
- package/vendor/rbxutil/component/wally.toml +14 -14
- package/vendor/rbxutil/concur/init.luau +542 -542
- package/vendor/rbxutil/concur/init.test.luau +364 -364
- package/vendor/rbxutil/concur/wally.toml +8 -8
- package/vendor/rbxutil/enum-list/init.luau +101 -101
- package/vendor/rbxutil/enum-list/init.test.luau +91 -91
- package/vendor/rbxutil/enum-list/wally.toml +8 -8
- package/vendor/rbxutil/find/index.d.ts +20 -20
- package/vendor/rbxutil/find/init.luau +44 -44
- package/vendor/rbxutil/find/package.json +17 -17
- package/vendor/rbxutil/find/wally.toml +8 -8
- package/vendor/rbxutil/input/Gamepad.luau +559 -559
- package/vendor/rbxutil/input/Keyboard.luau +124 -124
- package/vendor/rbxutil/input/Mouse.luau +278 -278
- package/vendor/rbxutil/input/PreferredInput.luau +91 -91
- package/vendor/rbxutil/input/Touch.luau +120 -120
- package/vendor/rbxutil/input/init.luau +33 -33
- package/vendor/rbxutil/input/wally.toml +12 -12
- package/vendor/rbxutil/loader/index.d.ts +15 -15
- package/vendor/rbxutil/loader/init.luau +137 -137
- package/vendor/rbxutil/loader/wally.toml +8 -8
- package/vendor/rbxutil/log/index.d.ts +38 -38
- package/vendor/rbxutil/log/init.luau +746 -746
- package/vendor/rbxutil/log/wally.toml +8 -8
- package/vendor/rbxutil/net/init.luau +190 -190
- package/vendor/rbxutil/net/wally.toml +8 -8
- package/vendor/rbxutil/option/index.d.ts +44 -44
- package/vendor/rbxutil/option/init.luau +489 -489
- package/vendor/rbxutil/option/init.test.luau +342 -342
- package/vendor/rbxutil/option/wally.toml +8 -8
- package/vendor/rbxutil/pid/index.d.ts +53 -53
- package/vendor/rbxutil/pid/init.luau +195 -195
- package/vendor/rbxutil/pid/package.json +16 -16
- package/vendor/rbxutil/pid/wally.toml +9 -9
- package/vendor/rbxutil/quaternion/index.d.ts +117 -117
- package/vendor/rbxutil/quaternion/init.luau +570 -570
- package/vendor/rbxutil/quaternion/package.json +16 -16
- package/vendor/rbxutil/quaternion/wally.toml +9 -9
- package/vendor/rbxutil/query/index.d.ts +43 -43
- package/vendor/rbxutil/query/init.luau +117 -117
- package/vendor/rbxutil/query/package.json +18 -18
- package/vendor/rbxutil/query/wally.toml +9 -9
- package/vendor/rbxutil/sequent/index.d.ts +28 -28
- package/vendor/rbxutil/sequent/init.luau +340 -340
- package/vendor/rbxutil/sequent/package.json +16 -16
- package/vendor/rbxutil/sequent/wally.toml +9 -9
- package/vendor/rbxutil/ser/init.luau +175 -175
- package/vendor/rbxutil/ser/init.test.luau +50 -50
- package/vendor/rbxutil/ser/wally.toml +11 -11
- package/vendor/rbxutil/shake/index.d.ts +36 -36
- package/vendor/rbxutil/shake/init.luau +532 -532
- package/vendor/rbxutil/shake/init.test.luau +267 -267
- package/vendor/rbxutil/shake/package.json +16 -16
- package/vendor/rbxutil/shake/wally.toml +9 -9
- package/vendor/rbxutil/signal/index.d.ts +100 -100
- package/vendor/rbxutil/signal/init.luau +432 -432
- package/vendor/rbxutil/signal/init.test.luau +190 -190
- package/vendor/rbxutil/signal/package.json +17 -17
- package/vendor/rbxutil/signal/wally.toml +9 -9
- package/vendor/rbxutil/silo/TableWatcher.luau +65 -65
- package/vendor/rbxutil/silo/Util.luau +55 -55
- package/vendor/rbxutil/silo/init.luau +338 -338
- package/vendor/rbxutil/silo/init.test.luau +215 -215
- package/vendor/rbxutil/silo/wally.toml +8 -8
- package/vendor/rbxutil/spring/index.d.ts +40 -40
- package/vendor/rbxutil/spring/init.luau +97 -97
- package/vendor/rbxutil/spring/package.json +17 -17
- package/vendor/rbxutil/spring/wally.toml +8 -8
- package/vendor/rbxutil/stream/index.d.ts +88 -88
- package/vendor/rbxutil/stream/init.luau +597 -597
- package/vendor/rbxutil/stream/package.json +18 -18
- package/vendor/rbxutil/stream/wally.toml +9 -9
- package/vendor/rbxutil/streamable/Streamable.luau +202 -202
- package/vendor/rbxutil/streamable/StreamableUtil.luau +80 -80
- package/vendor/rbxutil/streamable/init.luau +8 -8
- package/vendor/rbxutil/streamable/wally.toml +12 -12
- package/vendor/rbxutil/symbol/init.luau +56 -56
- package/vendor/rbxutil/symbol/init.test.luau +37 -37
- package/vendor/rbxutil/symbol/wally.toml +8 -8
- package/vendor/rbxutil/table-util/init.luau +938 -938
- package/vendor/rbxutil/table-util/init.test.luau +439 -439
- package/vendor/rbxutil/task-queue/index.d.ts +27 -27
- package/vendor/rbxutil/task-queue/init.luau +97 -97
- package/vendor/rbxutil/task-queue/wally.toml +8 -8
- package/vendor/rbxutil/timer/index.d.ts +81 -81
- package/vendor/rbxutil/timer/init.luau +249 -249
- package/vendor/rbxutil/timer/init.test.luau +73 -73
- package/vendor/rbxutil/timer/wally.toml +11 -11
- package/vendor/rbxutil/tree/index.d.ts +15 -15
- package/vendor/rbxutil/tree/init.luau +137 -137
- package/vendor/rbxutil/tree/wally.toml +8 -8
- package/vendor/rbxutil/trove/index.d.ts +46 -46
- package/vendor/rbxutil/trove/init.luau +787 -787
- package/vendor/rbxutil/trove/init.test.luau +203 -203
- package/vendor/rbxutil/trove/wally.toml +8 -8
- package/vendor/rbxutil/typed-remote/init.luau +196 -196
- package/vendor/rbxutil/typed-remote/wally.toml +8 -8
- package/vendor/rbxutil/wait-for/index.d.ts +17 -17
- package/vendor/rbxutil/wait-for/init.luau +257 -257
- package/vendor/rbxutil/wait-for/init.test.luau +182 -182
- package/vendor/rbxutil/wait-for/wally.toml +11 -11
- package/vendor/t/t.lua +1350 -1350
- package/vendor/testez/Context.lua +26 -26
- package/vendor/testez/Expectation.lua +311 -311
- package/vendor/testez/ExpectationContext.lua +38 -38
- package/vendor/testez/LifecycleHooks.lua +89 -89
- package/vendor/testez/Reporters/TeamCityReporter.lua +101 -101
- package/vendor/testez/Reporters/TextReporter.lua +105 -105
- package/vendor/testez/Reporters/TextReporterQuiet.lua +96 -96
- package/vendor/testez/TestBootstrap.lua +146 -146
- package/vendor/testez/TestEnum.lua +27 -27
- package/vendor/testez/TestPlan.lua +304 -304
- package/vendor/testez/TestPlanner.lua +39 -39
- package/vendor/testez/TestResults.lua +111 -111
- package/vendor/testez/TestRunner.lua +188 -188
- package/vendor/testez/TestSession.lua +243 -243
- package/vendor/testez/init.lua +39 -39
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!nolint LocalUnused
|
|
3
|
-
--!nolint LocalShadow
|
|
4
|
-
local task = nil -- Disable usage of Roblox's task scheduler
|
|
5
|
-
|
|
6
|
-
--[[
|
|
7
|
-
Returns a 2x2 matrix of coefficients for a given time, damping and angular
|
|
8
|
-
frequency (aka 'speed').
|
|
9
|
-
|
|
10
|
-
Specifically, this returns four coefficients - posPos, posVel, velPos, and
|
|
11
|
-
velVel - which can be multiplied with position and velocity like so:
|
|
12
|
-
|
|
13
|
-
local newPosition = oldPosition * posPos + oldVelocity * posVel
|
|
14
|
-
local newVelocity = oldPosition * velPos + oldVelocity * velVel
|
|
15
|
-
|
|
16
|
-
For speed = 1 and damping = 0, the result is a simple harmonic oscillator
|
|
17
|
-
with a period of tau.
|
|
18
|
-
|
|
19
|
-
Special thanks to AxisAngle for helping to improve numerical precision.
|
|
20
|
-
]]
|
|
21
|
-
|
|
22
|
-
local function springCoefficients(
|
|
23
|
-
time: number,
|
|
24
|
-
damping: number,
|
|
25
|
-
speed: number
|
|
26
|
-
): (number, number, number, number)
|
|
27
|
-
-- if time or speed is 0, then the spring won't move
|
|
28
|
-
if time == 0 or speed == 0 then
|
|
29
|
-
return 1, 0, 0, 1
|
|
30
|
-
end
|
|
31
|
-
local posPos, posVel, velPos, velVel
|
|
32
|
-
|
|
33
|
-
if damping > 1 then
|
|
34
|
-
-- overdamped spring
|
|
35
|
-
|
|
36
|
-
local alpha = math.sqrt(damping^2 - 1)
|
|
37
|
-
local negHalf_over_alpha_speed = -0.5 / (alpha * speed)
|
|
38
|
-
local z1 = speed * (alpha + damping) * -1
|
|
39
|
-
local z2 = speed * (alpha - damping)
|
|
40
|
-
local exp1 = math.exp(time * z1)
|
|
41
|
-
local exp2 = math.exp(time * z2)
|
|
42
|
-
|
|
43
|
-
posPos = (exp2 * z1 - exp1 * z2) * negHalf_over_alpha_speed
|
|
44
|
-
posVel = (exp1 - exp2) * negHalf_over_alpha_speed / speed
|
|
45
|
-
velPos = (exp2 - exp1) * negHalf_over_alpha_speed * speed
|
|
46
|
-
velVel = (exp1 * z1 - exp2 * z2) * negHalf_over_alpha_speed
|
|
47
|
-
|
|
48
|
-
elseif damping == 1 then
|
|
49
|
-
-- critically damped spring
|
|
50
|
-
|
|
51
|
-
local time_speed = time * speed
|
|
52
|
-
local time_speed_neg1 = time_speed * -1
|
|
53
|
-
local exp = math.exp(time_speed_neg1)
|
|
54
|
-
|
|
55
|
-
posPos = exp * (time_speed + 1)
|
|
56
|
-
posVel = exp * time
|
|
57
|
-
velPos = exp * (time_speed_neg1 * speed)
|
|
58
|
-
velVel = exp * (time_speed_neg1 + 1)
|
|
59
|
-
else
|
|
60
|
-
-- underdamped spring
|
|
61
|
-
|
|
62
|
-
local alpha = speed * math.sqrt(1 - damping^2)
|
|
63
|
-
local overAlpha = 1 / alpha
|
|
64
|
-
local exp = math.exp(-1 * time * speed * damping)
|
|
65
|
-
local sin = math.sin(alpha * time)
|
|
66
|
-
local cos = math.cos(alpha * time)
|
|
67
|
-
local exp_sin = exp * sin
|
|
68
|
-
local exp_cos = exp * cos
|
|
69
|
-
local exp_sin_speed_damping_overAlpha = exp_sin * speed * damping * overAlpha
|
|
70
|
-
|
|
71
|
-
posPos = exp_sin_speed_damping_overAlpha + exp_cos
|
|
72
|
-
posVel = exp_sin * overAlpha
|
|
73
|
-
velPos = -1 * ( exp_sin * alpha + speed * damping * exp_sin_speed_damping_overAlpha )
|
|
74
|
-
velVel = exp_cos - exp_sin_speed_damping_overAlpha
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
return posPos, posVel, velPos, velVel
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
return springCoefficients
|
|
1
|
+
--!strict
|
|
2
|
+
--!nolint LocalUnused
|
|
3
|
+
--!nolint LocalShadow
|
|
4
|
+
local task = nil -- Disable usage of Roblox's task scheduler
|
|
5
|
+
|
|
6
|
+
--[[
|
|
7
|
+
Returns a 2x2 matrix of coefficients for a given time, damping and angular
|
|
8
|
+
frequency (aka 'speed').
|
|
9
|
+
|
|
10
|
+
Specifically, this returns four coefficients - posPos, posVel, velPos, and
|
|
11
|
+
velVel - which can be multiplied with position and velocity like so:
|
|
12
|
+
|
|
13
|
+
local newPosition = oldPosition * posPos + oldVelocity * posVel
|
|
14
|
+
local newVelocity = oldPosition * velPos + oldVelocity * velVel
|
|
15
|
+
|
|
16
|
+
For speed = 1 and damping = 0, the result is a simple harmonic oscillator
|
|
17
|
+
with a period of tau.
|
|
18
|
+
|
|
19
|
+
Special thanks to AxisAngle for helping to improve numerical precision.
|
|
20
|
+
]]
|
|
21
|
+
|
|
22
|
+
local function springCoefficients(
|
|
23
|
+
time: number,
|
|
24
|
+
damping: number,
|
|
25
|
+
speed: number
|
|
26
|
+
): (number, number, number, number)
|
|
27
|
+
-- if time or speed is 0, then the spring won't move
|
|
28
|
+
if time == 0 or speed == 0 then
|
|
29
|
+
return 1, 0, 0, 1
|
|
30
|
+
end
|
|
31
|
+
local posPos, posVel, velPos, velVel
|
|
32
|
+
|
|
33
|
+
if damping > 1 then
|
|
34
|
+
-- overdamped spring
|
|
35
|
+
|
|
36
|
+
local alpha = math.sqrt(damping^2 - 1)
|
|
37
|
+
local negHalf_over_alpha_speed = -0.5 / (alpha * speed)
|
|
38
|
+
local z1 = speed * (alpha + damping) * -1
|
|
39
|
+
local z2 = speed * (alpha - damping)
|
|
40
|
+
local exp1 = math.exp(time * z1)
|
|
41
|
+
local exp2 = math.exp(time * z2)
|
|
42
|
+
|
|
43
|
+
posPos = (exp2 * z1 - exp1 * z2) * negHalf_over_alpha_speed
|
|
44
|
+
posVel = (exp1 - exp2) * negHalf_over_alpha_speed / speed
|
|
45
|
+
velPos = (exp2 - exp1) * negHalf_over_alpha_speed * speed
|
|
46
|
+
velVel = (exp1 * z1 - exp2 * z2) * negHalf_over_alpha_speed
|
|
47
|
+
|
|
48
|
+
elseif damping == 1 then
|
|
49
|
+
-- critically damped spring
|
|
50
|
+
|
|
51
|
+
local time_speed = time * speed
|
|
52
|
+
local time_speed_neg1 = time_speed * -1
|
|
53
|
+
local exp = math.exp(time_speed_neg1)
|
|
54
|
+
|
|
55
|
+
posPos = exp * (time_speed + 1)
|
|
56
|
+
posVel = exp * time
|
|
57
|
+
velPos = exp * (time_speed_neg1 * speed)
|
|
58
|
+
velVel = exp * (time_speed_neg1 + 1)
|
|
59
|
+
else
|
|
60
|
+
-- underdamped spring
|
|
61
|
+
|
|
62
|
+
local alpha = speed * math.sqrt(1 - damping^2)
|
|
63
|
+
local overAlpha = 1 / alpha
|
|
64
|
+
local exp = math.exp(-1 * time * speed * damping)
|
|
65
|
+
local sin = math.sin(alpha * time)
|
|
66
|
+
local cos = math.cos(alpha * time)
|
|
67
|
+
local exp_sin = exp * sin
|
|
68
|
+
local exp_cos = exp * cos
|
|
69
|
+
local exp_sin_speed_damping_overAlpha = exp_sin * speed * damping * overAlpha
|
|
70
|
+
|
|
71
|
+
posPos = exp_sin_speed_damping_overAlpha + exp_cos
|
|
72
|
+
posVel = exp_sin * overAlpha
|
|
73
|
+
velPos = -1 * ( exp_sin * alpha + speed * damping * exp_sin_speed_damping_overAlpha )
|
|
74
|
+
velVel = exp_cos - exp_sin_speed_damping_overAlpha
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
return posPos, posVel, velPos, velVel
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
return springCoefficients
|
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!nolint LocalUnused
|
|
3
|
-
--!nolint LocalShadow
|
|
4
|
-
local task = nil -- Disable usage of Roblox's task scheduler
|
|
5
|
-
|
|
6
|
-
--[[
|
|
7
|
-
Unpacks an animatable type into an array of numbers.
|
|
8
|
-
If the type is not animatable, an empty array will be returned.
|
|
9
|
-
]]
|
|
10
|
-
|
|
11
|
-
local Package = script.Parent.Parent
|
|
12
|
-
local Oklab = require(Package.Colour.Oklab)
|
|
13
|
-
|
|
14
|
-
local function unpackType(
|
|
15
|
-
value: unknown,
|
|
16
|
-
typeString: string
|
|
17
|
-
): {number}
|
|
18
|
-
if typeString == "number" then
|
|
19
|
-
local value = value :: number
|
|
20
|
-
return {value}
|
|
21
|
-
|
|
22
|
-
elseif typeString == "CFrame" then
|
|
23
|
-
local value = value :: CFrame
|
|
24
|
-
-- FUTURE: is there a better way of doing this? doing distance
|
|
25
|
-
-- calculations on `angle` may be incorrect
|
|
26
|
-
local axis, angle = value:ToAxisAngle()
|
|
27
|
-
return {value.X, value.Y, value.Z, axis.X, axis.Y, axis.Z, angle}
|
|
28
|
-
|
|
29
|
-
elseif typeString == "Color3" then
|
|
30
|
-
local value = value :: Color3
|
|
31
|
-
local lab = Oklab.fromSRGB(value)
|
|
32
|
-
return {lab.X, lab.Y, lab.Z}
|
|
33
|
-
|
|
34
|
-
elseif typeString == "ColorSequenceKeypoint" then
|
|
35
|
-
local value = value :: ColorSequenceKeypoint
|
|
36
|
-
local lab = Oklab.fromSRGB(value.Value)
|
|
37
|
-
return {lab.X, lab.Y, lab.Z, value.Time}
|
|
38
|
-
|
|
39
|
-
elseif typeString == "DateTime" then
|
|
40
|
-
local value = value :: DateTime
|
|
41
|
-
return {value.UnixTimestampMillis}
|
|
42
|
-
|
|
43
|
-
elseif typeString == "NumberRange" then
|
|
44
|
-
local value = value :: NumberRange
|
|
45
|
-
return {value.Min, value.Max}
|
|
46
|
-
|
|
47
|
-
elseif typeString == "NumberSequenceKeypoint" then
|
|
48
|
-
local value = value :: NumberSequenceKeypoint
|
|
49
|
-
return {value.Value, value.Time, value.Envelope}
|
|
50
|
-
|
|
51
|
-
elseif typeString == "PhysicalProperties" then
|
|
52
|
-
local value = value :: PhysicalProperties
|
|
53
|
-
return {value.Density, value.Friction, value.Elasticity, value.FrictionWeight, value.ElasticityWeight}
|
|
54
|
-
|
|
55
|
-
elseif typeString == "Ray" then
|
|
56
|
-
local value = value :: Ray
|
|
57
|
-
return {value.Origin.X, value.Origin.Y, value.Origin.Z, value.Direction.X, value.Direction.Y, value.Direction.Z}
|
|
58
|
-
|
|
59
|
-
elseif typeString == "Rect" then
|
|
60
|
-
local value = value :: Rect
|
|
61
|
-
return {value.Min.X, value.Min.Y, value.Max.X, value.Max.Y}
|
|
62
|
-
|
|
63
|
-
elseif typeString == "Region3" then
|
|
64
|
-
local value = value :: Region3
|
|
65
|
-
-- FUTURE: support rotated Region3s if/when they become constructable
|
|
66
|
-
return {
|
|
67
|
-
value.CFrame.X, value.CFrame.Y, value.CFrame.Z,
|
|
68
|
-
value.Size.X, value.Size.Y, value.Size.Z
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
elseif typeString == "Region3int16" then
|
|
72
|
-
local value = value :: Region3int16
|
|
73
|
-
return {value.Min.X, value.Min.Y, value.Min.Z, value.Max.X, value.Max.Y, value.Max.Z}
|
|
74
|
-
|
|
75
|
-
elseif typeString == "UDim" then
|
|
76
|
-
local value = value :: UDim
|
|
77
|
-
return {value.Scale, value.Offset}
|
|
78
|
-
|
|
79
|
-
elseif typeString == "UDim2" then
|
|
80
|
-
local value = value :: UDim2
|
|
81
|
-
return {value.X.Scale, value.X.Offset, value.Y.Scale, value.Y.Offset}
|
|
82
|
-
|
|
83
|
-
elseif typeString == "Vector2" then
|
|
84
|
-
local value = value :: Vector2
|
|
85
|
-
return {value.X, value.Y}
|
|
86
|
-
|
|
87
|
-
elseif typeString == "Vector2int16" then
|
|
88
|
-
local value = value :: Vector2int16
|
|
89
|
-
return {value.X, value.Y}
|
|
90
|
-
|
|
91
|
-
elseif typeString == "Vector3" then
|
|
92
|
-
local value = value :: Vector3
|
|
93
|
-
return {value.X, value.Y, value.Z}
|
|
94
|
-
|
|
95
|
-
elseif typeString == "Vector3int16" then
|
|
96
|
-
local value = value :: Vector3int16
|
|
97
|
-
return {value.X, value.Y, value.Z}
|
|
98
|
-
else
|
|
99
|
-
return {}
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
1
|
+
--!strict
|
|
2
|
+
--!nolint LocalUnused
|
|
3
|
+
--!nolint LocalShadow
|
|
4
|
+
local task = nil -- Disable usage of Roblox's task scheduler
|
|
5
|
+
|
|
6
|
+
--[[
|
|
7
|
+
Unpacks an animatable type into an array of numbers.
|
|
8
|
+
If the type is not animatable, an empty array will be returned.
|
|
9
|
+
]]
|
|
10
|
+
|
|
11
|
+
local Package = script.Parent.Parent
|
|
12
|
+
local Oklab = require(Package.Colour.Oklab)
|
|
13
|
+
|
|
14
|
+
local function unpackType(
|
|
15
|
+
value: unknown,
|
|
16
|
+
typeString: string
|
|
17
|
+
): {number}
|
|
18
|
+
if typeString == "number" then
|
|
19
|
+
local value = value :: number
|
|
20
|
+
return {value}
|
|
21
|
+
|
|
22
|
+
elseif typeString == "CFrame" then
|
|
23
|
+
local value = value :: CFrame
|
|
24
|
+
-- FUTURE: is there a better way of doing this? doing distance
|
|
25
|
+
-- calculations on `angle` may be incorrect
|
|
26
|
+
local axis, angle = value:ToAxisAngle()
|
|
27
|
+
return {value.X, value.Y, value.Z, axis.X, axis.Y, axis.Z, angle}
|
|
28
|
+
|
|
29
|
+
elseif typeString == "Color3" then
|
|
30
|
+
local value = value :: Color3
|
|
31
|
+
local lab = Oklab.fromSRGB(value)
|
|
32
|
+
return {lab.X, lab.Y, lab.Z}
|
|
33
|
+
|
|
34
|
+
elseif typeString == "ColorSequenceKeypoint" then
|
|
35
|
+
local value = value :: ColorSequenceKeypoint
|
|
36
|
+
local lab = Oklab.fromSRGB(value.Value)
|
|
37
|
+
return {lab.X, lab.Y, lab.Z, value.Time}
|
|
38
|
+
|
|
39
|
+
elseif typeString == "DateTime" then
|
|
40
|
+
local value = value :: DateTime
|
|
41
|
+
return {value.UnixTimestampMillis}
|
|
42
|
+
|
|
43
|
+
elseif typeString == "NumberRange" then
|
|
44
|
+
local value = value :: NumberRange
|
|
45
|
+
return {value.Min, value.Max}
|
|
46
|
+
|
|
47
|
+
elseif typeString == "NumberSequenceKeypoint" then
|
|
48
|
+
local value = value :: NumberSequenceKeypoint
|
|
49
|
+
return {value.Value, value.Time, value.Envelope}
|
|
50
|
+
|
|
51
|
+
elseif typeString == "PhysicalProperties" then
|
|
52
|
+
local value = value :: PhysicalProperties
|
|
53
|
+
return {value.Density, value.Friction, value.Elasticity, value.FrictionWeight, value.ElasticityWeight}
|
|
54
|
+
|
|
55
|
+
elseif typeString == "Ray" then
|
|
56
|
+
local value = value :: Ray
|
|
57
|
+
return {value.Origin.X, value.Origin.Y, value.Origin.Z, value.Direction.X, value.Direction.Y, value.Direction.Z}
|
|
58
|
+
|
|
59
|
+
elseif typeString == "Rect" then
|
|
60
|
+
local value = value :: Rect
|
|
61
|
+
return {value.Min.X, value.Min.Y, value.Max.X, value.Max.Y}
|
|
62
|
+
|
|
63
|
+
elseif typeString == "Region3" then
|
|
64
|
+
local value = value :: Region3
|
|
65
|
+
-- FUTURE: support rotated Region3s if/when they become constructable
|
|
66
|
+
return {
|
|
67
|
+
value.CFrame.X, value.CFrame.Y, value.CFrame.Z,
|
|
68
|
+
value.Size.X, value.Size.Y, value.Size.Z
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
elseif typeString == "Region3int16" then
|
|
72
|
+
local value = value :: Region3int16
|
|
73
|
+
return {value.Min.X, value.Min.Y, value.Min.Z, value.Max.X, value.Max.Y, value.Max.Z}
|
|
74
|
+
|
|
75
|
+
elseif typeString == "UDim" then
|
|
76
|
+
local value = value :: UDim
|
|
77
|
+
return {value.Scale, value.Offset}
|
|
78
|
+
|
|
79
|
+
elseif typeString == "UDim2" then
|
|
80
|
+
local value = value :: UDim2
|
|
81
|
+
return {value.X.Scale, value.X.Offset, value.Y.Scale, value.Y.Offset}
|
|
82
|
+
|
|
83
|
+
elseif typeString == "Vector2" then
|
|
84
|
+
local value = value :: Vector2
|
|
85
|
+
return {value.X, value.Y}
|
|
86
|
+
|
|
87
|
+
elseif typeString == "Vector2int16" then
|
|
88
|
+
local value = value :: Vector2int16
|
|
89
|
+
return {value.X, value.Y}
|
|
90
|
+
|
|
91
|
+
elseif typeString == "Vector3" then
|
|
92
|
+
local value = value :: Vector3
|
|
93
|
+
return {value.X, value.Y, value.Z}
|
|
94
|
+
|
|
95
|
+
elseif typeString == "Vector3int16" then
|
|
96
|
+
local value = value :: Vector3int16
|
|
97
|
+
return {value.X, value.Y, value.Z}
|
|
98
|
+
else
|
|
99
|
+
return {}
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
103
|
return unpackType
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!nolint LocalUnused
|
|
3
|
-
--!nolint LocalShadow
|
|
4
|
-
local task = nil -- Disable usage of Roblox's task scheduler
|
|
5
|
-
|
|
6
|
-
--[[
|
|
7
|
-
Provides functions for converting Color3s into Oklab space, for more
|
|
8
|
-
perceptually uniform colour blending.
|
|
9
|
-
|
|
10
|
-
See: https://bottosson.github.io/posts/oklab/
|
|
11
|
-
]]
|
|
12
|
-
|
|
13
|
-
local sRGB = require(script.Parent.sRGB)
|
|
14
|
-
|
|
15
|
-
local Oklab = {}
|
|
16
|
-
|
|
17
|
-
-- Converts a Color3 in linear RGB space to a Vector3 in Oklab space.
|
|
18
|
-
function Oklab.fromLinear(rgb: Color3): Vector3
|
|
19
|
-
|
|
20
|
-
local l = rgb.R * 0.4122214708 + rgb.G * 0.5363325363 + rgb.B * 0.0514459929
|
|
21
|
-
local m = rgb.R * 0.2119034982 + rgb.G * 0.6806995451 + rgb.B * 0.1073969566
|
|
22
|
-
local s = rgb.R * 0.0883024619 + rgb.G * 0.2817188376 + rgb.B * 0.6299787005
|
|
23
|
-
|
|
24
|
-
local lRoot = l ^ (1/3)
|
|
25
|
-
local mRoot = m ^ (1/3)
|
|
26
|
-
local sRoot = s ^ (1/3)
|
|
27
|
-
|
|
28
|
-
return Vector3.new(
|
|
29
|
-
lRoot * 0.2104542553 + mRoot * 0.7936177850 - sRoot * 0.0040720468,
|
|
30
|
-
lRoot * 1.9779984951 - mRoot * 2.4285922050 + sRoot * 0.4505937099,
|
|
31
|
-
lRoot * 0.0259040371 + mRoot * 0.7827717662 - sRoot * 0.8086757660
|
|
32
|
-
)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
-- Converts a Color3 in sRGB space to a Vector3 in Oklab space.
|
|
36
|
-
function Oklab.fromSRGB(srgb: Color3): Vector3
|
|
37
|
-
return Oklab.fromLinear(sRGB.toLinear(srgb))
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
-- Converts a Vector3 in Oklab space to a Color3 in linear RGB space.
|
|
41
|
-
-- The Color3 will be clamped by default unless specified otherwise.
|
|
42
|
-
function Oklab.toLinear(lab: Vector3, unclamped: boolean?): Color3
|
|
43
|
-
local lRoot = lab.X + lab.Y * 0.3963377774 + lab.Z * 0.2158037573
|
|
44
|
-
local mRoot = lab.X - lab.Y * 0.1055613458 - lab.Z * 0.0638541728
|
|
45
|
-
local sRoot = lab.X - lab.Y * 0.0894841775 - lab.Z * 1.2914855480
|
|
46
|
-
|
|
47
|
-
local l = lRoot ^ 3
|
|
48
|
-
local m = mRoot ^ 3
|
|
49
|
-
local s = sRoot ^ 3
|
|
50
|
-
|
|
51
|
-
local red = l * 4.0767416621 - m * 3.3077115913 + s * 0.2309699292
|
|
52
|
-
local green = l * -1.2684380046 + m * 2.6097574011 - s * 0.3413193965
|
|
53
|
-
local blue = l * -0.0041960863 - m * 0.7034186147 + s * 1.7076147010
|
|
54
|
-
|
|
55
|
-
if not unclamped then
|
|
56
|
-
red = math.clamp(red, 0, 1)
|
|
57
|
-
green = math.clamp(green, 0, 1)
|
|
58
|
-
blue = math.clamp(blue, 0, 1)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
return Color3.new(red, green, blue)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
-- Converts a Vector3 in Oklab space to a Color3 in sRGB space.
|
|
65
|
-
-- The Color3 will be clamped by default unless specified otherwise.
|
|
66
|
-
function Oklab.toSRGB(lab: Vector3, unclamped: boolean?): Color3
|
|
67
|
-
return sRGB.fromLinear(Oklab.toLinear(lab, unclamped))
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
return Oklab
|
|
1
|
+
--!strict
|
|
2
|
+
--!nolint LocalUnused
|
|
3
|
+
--!nolint LocalShadow
|
|
4
|
+
local task = nil -- Disable usage of Roblox's task scheduler
|
|
5
|
+
|
|
6
|
+
--[[
|
|
7
|
+
Provides functions for converting Color3s into Oklab space, for more
|
|
8
|
+
perceptually uniform colour blending.
|
|
9
|
+
|
|
10
|
+
See: https://bottosson.github.io/posts/oklab/
|
|
11
|
+
]]
|
|
12
|
+
|
|
13
|
+
local sRGB = require(script.Parent.sRGB)
|
|
14
|
+
|
|
15
|
+
local Oklab = {}
|
|
16
|
+
|
|
17
|
+
-- Converts a Color3 in linear RGB space to a Vector3 in Oklab space.
|
|
18
|
+
function Oklab.fromLinear(rgb: Color3): Vector3
|
|
19
|
+
|
|
20
|
+
local l = rgb.R * 0.4122214708 + rgb.G * 0.5363325363 + rgb.B * 0.0514459929
|
|
21
|
+
local m = rgb.R * 0.2119034982 + rgb.G * 0.6806995451 + rgb.B * 0.1073969566
|
|
22
|
+
local s = rgb.R * 0.0883024619 + rgb.G * 0.2817188376 + rgb.B * 0.6299787005
|
|
23
|
+
|
|
24
|
+
local lRoot = l ^ (1/3)
|
|
25
|
+
local mRoot = m ^ (1/3)
|
|
26
|
+
local sRoot = s ^ (1/3)
|
|
27
|
+
|
|
28
|
+
return Vector3.new(
|
|
29
|
+
lRoot * 0.2104542553 + mRoot * 0.7936177850 - sRoot * 0.0040720468,
|
|
30
|
+
lRoot * 1.9779984951 - mRoot * 2.4285922050 + sRoot * 0.4505937099,
|
|
31
|
+
lRoot * 0.0259040371 + mRoot * 0.7827717662 - sRoot * 0.8086757660
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
-- Converts a Color3 in sRGB space to a Vector3 in Oklab space.
|
|
36
|
+
function Oklab.fromSRGB(srgb: Color3): Vector3
|
|
37
|
+
return Oklab.fromLinear(sRGB.toLinear(srgb))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
-- Converts a Vector3 in Oklab space to a Color3 in linear RGB space.
|
|
41
|
+
-- The Color3 will be clamped by default unless specified otherwise.
|
|
42
|
+
function Oklab.toLinear(lab: Vector3, unclamped: boolean?): Color3
|
|
43
|
+
local lRoot = lab.X + lab.Y * 0.3963377774 + lab.Z * 0.2158037573
|
|
44
|
+
local mRoot = lab.X - lab.Y * 0.1055613458 - lab.Z * 0.0638541728
|
|
45
|
+
local sRoot = lab.X - lab.Y * 0.0894841775 - lab.Z * 1.2914855480
|
|
46
|
+
|
|
47
|
+
local l = lRoot ^ 3
|
|
48
|
+
local m = mRoot ^ 3
|
|
49
|
+
local s = sRoot ^ 3
|
|
50
|
+
|
|
51
|
+
local red = l * 4.0767416621 - m * 3.3077115913 + s * 0.2309699292
|
|
52
|
+
local green = l * -1.2684380046 + m * 2.6097574011 - s * 0.3413193965
|
|
53
|
+
local blue = l * -0.0041960863 - m * 0.7034186147 + s * 1.7076147010
|
|
54
|
+
|
|
55
|
+
if not unclamped then
|
|
56
|
+
red = math.clamp(red, 0, 1)
|
|
57
|
+
green = math.clamp(green, 0, 1)
|
|
58
|
+
blue = math.clamp(blue, 0, 1)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
return Color3.new(red, green, blue)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
-- Converts a Vector3 in Oklab space to a Color3 in sRGB space.
|
|
65
|
+
-- The Color3 will be clamped by default unless specified otherwise.
|
|
66
|
+
function Oklab.toSRGB(lab: Vector3, unclamped: boolean?): Color3
|
|
67
|
+
return sRGB.fromLinear(Oklab.toLinear(lab, unclamped))
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
return Oklab
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!nolint LocalUnused
|
|
3
|
-
--!nolint LocalShadow
|
|
4
|
-
local task = nil -- Disable usage of Roblox's task scheduler
|
|
5
|
-
|
|
6
|
-
--[[
|
|
7
|
-
Provides transformation functions for converting linear RGB values
|
|
8
|
-
into sRGB values.
|
|
9
|
-
|
|
10
|
-
RGB color channel transformations are outlined here:
|
|
11
|
-
https://bottosson.github.io/posts/colorwrong/#what-can-we-do%3F
|
|
12
|
-
]]
|
|
13
|
-
|
|
14
|
-
local sRGB = {}
|
|
15
|
-
|
|
16
|
-
-- Equivalent to f_inv. Takes a linear sRGB channel and returns
|
|
17
|
-
-- the sRGB channel
|
|
18
|
-
local function transform(channel: number): number
|
|
19
|
-
if channel >= 0.04045 then
|
|
20
|
-
return ((channel + 0.055)/(1 + 0.055))^2.4
|
|
21
|
-
else
|
|
22
|
-
return channel / 12.92
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
-- Equivalent to f. Takes an sRGB channel and returns
|
|
27
|
-
-- the linear sRGB channel
|
|
28
|
-
local function inverse(channel: number): number
|
|
29
|
-
if channel >= 0.0031308 then
|
|
30
|
-
return (1.055) * channel^(1.0/2.4) - 0.055
|
|
31
|
-
else
|
|
32
|
-
return 12.92 * channel
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
-- Uses a tranformation to convert linear RGB into sRGB.
|
|
37
|
-
function sRGB.fromLinear(rgb: Color3): Color3
|
|
38
|
-
return Color3.new(
|
|
39
|
-
transform(rgb.R),
|
|
40
|
-
transform(rgb.G),
|
|
41
|
-
transform(rgb.B)
|
|
42
|
-
)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
-- Converts an sRGB into linear RGB using a
|
|
46
|
-
-- (The inverse of sRGB.fromLinear).
|
|
47
|
-
function sRGB.toLinear(srgb: Color3): Color3
|
|
48
|
-
return Color3.new(
|
|
49
|
-
inverse(srgb.R),
|
|
50
|
-
inverse(srgb.G),
|
|
51
|
-
inverse(srgb.B)
|
|
52
|
-
)
|
|
53
|
-
end
|
|
54
|
-
|
|
1
|
+
--!strict
|
|
2
|
+
--!nolint LocalUnused
|
|
3
|
+
--!nolint LocalShadow
|
|
4
|
+
local task = nil -- Disable usage of Roblox's task scheduler
|
|
5
|
+
|
|
6
|
+
--[[
|
|
7
|
+
Provides transformation functions for converting linear RGB values
|
|
8
|
+
into sRGB values.
|
|
9
|
+
|
|
10
|
+
RGB color channel transformations are outlined here:
|
|
11
|
+
https://bottosson.github.io/posts/colorwrong/#what-can-we-do%3F
|
|
12
|
+
]]
|
|
13
|
+
|
|
14
|
+
local sRGB = {}
|
|
15
|
+
|
|
16
|
+
-- Equivalent to f_inv. Takes a linear sRGB channel and returns
|
|
17
|
+
-- the sRGB channel
|
|
18
|
+
local function transform(channel: number): number
|
|
19
|
+
if channel >= 0.04045 then
|
|
20
|
+
return ((channel + 0.055)/(1 + 0.055))^2.4
|
|
21
|
+
else
|
|
22
|
+
return channel / 12.92
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
-- Equivalent to f. Takes an sRGB channel and returns
|
|
27
|
+
-- the linear sRGB channel
|
|
28
|
+
local function inverse(channel: number): number
|
|
29
|
+
if channel >= 0.0031308 then
|
|
30
|
+
return (1.055) * channel^(1.0/2.4) - 0.055
|
|
31
|
+
else
|
|
32
|
+
return 12.92 * channel
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
-- Uses a tranformation to convert linear RGB into sRGB.
|
|
37
|
+
function sRGB.fromLinear(rgb: Color3): Color3
|
|
38
|
+
return Color3.new(
|
|
39
|
+
transform(rgb.R),
|
|
40
|
+
transform(rgb.G),
|
|
41
|
+
transform(rgb.B)
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
-- Converts an sRGB into linear RGB using a
|
|
46
|
+
-- (The inverse of sRGB.fromLinear).
|
|
47
|
+
function sRGB.toLinear(srgb: Color3): Color3
|
|
48
|
+
return Color3.new(
|
|
49
|
+
inverse(srgb.R),
|
|
50
|
+
inverse(srgb.G),
|
|
51
|
+
inverse(srgb.B)
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
55
|
return sRGB
|