Created
January 7, 2015 06:48
-
-
Save torque/194882dea13dd9f60c2f to your computer and use it in GitHub Desktop.
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
convertClipToFP = ( clip ) -> | |
-- only muck around with vector clips (convert scaling factor into floating point coordinates). | |
unless clip\match "[%-%d%.]+, *[%-%d%.]+" | |
-- Convert clip with scale into floating point coordinates. | |
clip = clip\gsub "%((%d*),?(.-)%)", ( scaleFactor, points ) -> | |
if scaleFactor ~= "" | |
scaleFactor = tonumber scaleFactor | |
points = points\gsub "([%.%d%-]+) ([%.%d%-]+)", ( x, y ) -> | |
x = Math.round tonumber( x )/(2^(scaleFactor - 1)), 2 | |
y = Math.round tonumber( y )/(2^(scaleFactor - 1)), 2 | |
("%g %g")\format x, y | |
return '(' .. points .. ')' | |
return clip | |
dongs = (sub,sel,act) -> | |
for index in *sel | |
with line = sub[index] | |
line.text = line.text\gsub "({.-})", (override) -> | |
return override\gsub "(\\i?clip)(%(.-%))", (tag, clip) -> | |
return tag .. convertClipToFP(clip) | |
sub[index] = line | |
aegisub.register_macro "megadongs", "megadongs", dongs | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment