Skip to content

Instantly share code, notes, and snippets.

@GigsD4X
GigsD4X / HSVtoRGB.lua
Created January 20, 2014 02:31
Returns the RGB equivalent of the given HSV data, or vice-versa. Adapted from http://www.cs.rit.edu/~ncs/color/t_convert.html
function HSVToRGB( hue, saturation, value )
-- Returns the RGB equivalent of the given HSV-defined color
-- (adapted from some code found around the web)
-- If it's achromatic, just return the value
if saturation == 0 then
return value;
end;
-- Get the hue sector
@GigsD4X
GigsD4X / getInterequidistantlyScaledFrames.lua
Created September 28, 2013 04:07
Returns a table with a given number of frames positioned on a scale from 0 to 1 along a given dimension in a way where they all fit with equal spacing in between them, aligned to a given end of the dimension.
function getInterequidistantlyScaledFrames( count, padding, dimension, alignment )
-- Returns a table containing `count` Frame objects with `padding`
-- percent of the frame size (on a scale from 0 to 1) of spacing in
-- between each frame in the "x" or "y" `dimension`, aligned to the
-- "left", "center", or "right" (or, along the y-axis, "top",
-- "center", or "bottom")
local frames = {};
-- Calculate the size of each frame considering the padding in
@GigsD4X
GigsD4X / findPatternInChildScripts.lua
Last active December 20, 2015 10:49
Prints instances of the given case-insensitive pattern in any scripts within a given object. Usage: findPatternInChildScripts( `Parent`, `pattern` )
function _trimString( str )
-- Returns string `str` without leading/trailing whitespace
return ( str:gsub( "^%s*(.-)%s*$", "%1" ) );
end;
function _countStringOccurrences( haystack, needle )
-- Returns the amount of occurrences of a pattern in a string
local count = 0;
for _ in haystack:gmatch( needle ) do