Skip to content

Instantly share code, notes, and snippets.

@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)