Skip to content

Instantly share code, notes, and snippets.

View Pyseph's full-sized avatar

Pyseph Pyseph

  • 17:23 (UTC +02:00)
View GitHub Profile
@Pyseph
Pyseph / GetBoundingBox.luau
Last active March 9, 2025 05:40
get bounding box of a Roblox model including particle emitters
--!strict
-- distance traveled from t=0..lifetime if Drag>0 means half-life=drag
local function ComputeDragFactor(drag: number, lifetime: number): number
-- if Drag = 0, theres no exponential change in speed
if drag == 0 then
return 1
end
-- 'rate' = drag * ln(2). this is the exponent's coefficient in e^( ... )
local rate = drag * math.log(2)
@Pyseph
Pyseph / ImgStrokeModule.luau
Created January 31, 2025 12:32
an optimized stroke generation module for images, utilizing Roblox's EditableImage, Felzenszwalb & Huttenloche's 1D exact distance transform algorithm, and bitswitching for squeezing out the most performance.
local module = {}
--MCR, Jan 2025
--Will return an editImage, the old size, and the new size if required
--eg: a 100x100 image with a 4 stroke will come back as 110x110 -> stroke * 2 + 2
--Also doesnt check for upper image size
-- NO LONGER SLOW! optimized by Pyseph :-)
function module:MakeStrokeImageFromAssetIdAsync(assetId : number, strokeSize : number) : EditableImage?
strokeSize = math.clamp(strokeSize, 1, 16)
@Pyseph
Pyseph / CustomEnum.luau
Last active October 19, 2024 15:10
Custom Enum class for Roblox
--[[
EXAMPLE USAGE:
local BaseState = CustomEnum.Class.new("BaseState", {
"Dead",
"Alive",
"Walking",
})
local SubState = CustomEnum.Class.New("CombatStates", {
"Attacking",