This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local fuzzy = { | |
NOT = function(x) | |
return 1 - x | |
end; | |
AND = function(x, y) | |
return x*y | |
end; | |
OR = function(x, y) | |
return x + y - x*y | |
end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local LerpCIELUV do | |
-- Combines two colors in CIELUV space. | |
-- function<function<Color3 result>(float t)>(Color3 fromColor, Color3 toColor) | |
-- https://www.w3.org/Graphics/Color/srgb | |
local clamp = math.clamp | |
local C3 = Color3.new | |
local black = C3(0, 0, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ln = math.log | |
local abs = math.abs | |
local sin = math.sin | |
local cos = math.cos | |
local exp = math.exp | |
local acos = math.acos | |
local sqrt = math.sqrt | |
local function MulLn(w0, x0, y0, z0, w1, x1, y1, z1) | |
local w, x, y, z = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function hostos() | |
local msvc | |
local posix | |
for _ = 1, 8 do | |
local k = math.random() | |
msvc = 0 == k*0x7FFF%1 | |
posix = 0 == k*0x7FFFFFFF%1 | |
if msvc ~= posix then | |
break | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local camera, cameraChanged | |
local viewport, viewportChanged | |
-- Challenge: | |
-- 1. Make `camera' always point to the the current or last known camera. | |
-- a. Problem: CurrentCamera can be nil. | |
-- b. Guarantee that `camera' is never nil. | |
-- 2. Make `viewport' always be the current actual size of the viewport. | |
-- a. Problem: ViewportSize can falsely report (1,1) before it gets fixed up by RenderPrepare. | |
-- b. Guarantee that `viewport' is never (1,1). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Spring = {} do | |
Spring.__index = Spring | |
local pi = math.pi | |
local exp = math.exp | |
local sin = math.sin | |
local cos = math.cos | |
local sqrt = math.sqrt | |
function Spring.new(dampingRatio, frequency, position) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Dumpster = {} do | |
Dumpster.__index = Dumpster | |
local finalizers = setmetatable( | |
{ | |
["function"] = function(item) | |
return item() | |
end, | |
["Instance"] = game.Destroy, | |
["RBXScriptConnection"] = Instance.new("BindableEvent").Event:Connect(function() end).Disconnect, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Vector3 guiPointToWorld(SurfaceGui gui, Vector2 point) | |
-- SurfaceGui space -> world space | |
local function guiPointToWorld(gui, point) | |
local adornee = assert(gui.Adornee) | |
local normalizedPoint = point/gui.AbsoluteSize | |
local dir = Vector3.FromNormalId(gui.Face) | |
local projY = math.abs(dir.z + dir.x) | |
local projZ = dir.x + math.abs(dir.y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Evaluate a string from a parametric input box and return a number. | |
-- Expressions are sandboxed with access to standard Lua math functions. | |
local parametricEval do | |
local envTemplate = { | |
abs = math.abs, | |
acos = math.acos, | |
asin = math.asin, | |
atan = math.atan, | |
atan2 = math.atan2, | |
ceil = math.ceil, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Various ways of testing a screen point against a GuiBase2d | |
-- Note: Rounded rect corner radius is inferred from SliceCenter.Min.X | |
local cos = math.cos | |
local min = math.min | |
local rad = math.rad | |
local sin = math.sin | |
return { | |
-- Axis-aligned rectangle |
OlderNewer