aboutsummaryrefslogtreecommitdiffstats
path: root/macros/garret.inverse-glow.lua
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2021-12-23 13:04:43 +0000
committergarret <garret@airmail.cc>2021-12-23 13:04:43 +0000
commit8e13d9167e8f4c05a8901f673bb34c2c99b7041d (patch)
treecf7a7ecaecde55330a88f8f52c8d164163dc574f /macros/garret.inverse-glow.lua
parent140b7f3fd2fbc6fb07121dacd60a5bee1c5f5d41 (diff)
downloadaegisub-scripts-8e13d9167e8f4c05a8901f673bb34c2c99b7041d.tar.gz
aegisub-scripts-8e13d9167e8f4c05a8901f673bb34c2c99b7041d.tar.bz2
aegisub-scripts-8e13d9167e8f4c05a8901f673bb34c2c99b7041d.zip
new script
Diffstat (limited to 'macros/garret.inverse-glow.lua')
-rw-r--r--macros/garret.inverse-glow.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/macros/garret.inverse-glow.lua b/macros/garret.inverse-glow.lua
new file mode 100644
index 0000000..9733424
--- /dev/null
+++ b/macros/garret.inverse-glow.lua
@@ -0,0 +1,55 @@
+script_name = "Inverse Glow"
+script_description = "glow but it goes inside the letter"
+script_author = "garret"
+script_version = "1.0.0"
+script_namespace = "garret.inverse-glow"
+
+local haveDepCtrl, DependencyControl, depctrl = pcall(require, "l0.DependencyControl")
+local util
+if haveDepCtrl then
+ depctrl = DependencyControl({
+ --feed="TODO",
+ { "aegisub.util" },
+ })
+ util = depctrl:requireModules()
+else
+ util = require("aegisub.util")
+end
+
+local patterns = { tags_text = "(%b{})(.*)", bord = "\\bord(%d+)", dark = "\\c(&?H*%x+&?)", light = "\\3c(&?H*%x+&?)" }
+
+local function main(subs, sel)
+ for i = #sel, 1, -1 do
+ local line = subs[sel[i]]
+ local tags, text = line.text:match(patterns.tags_text)
+ local blur = string.match(tags, patterns.bord) -- \bord = value of \blur
+ local dark = tags:match(patterns.dark) -- \c = colour of dark layer
+ local light = tags:match(patterns.light) -- \3c = colour of light layer
+
+ if tags and blur and dark and light then -- skip lines that don't have everything needed
+ tags = string.gsub(tags, patterns.bord, "") -- remove \bord
+ tags = string.gsub(tags, patterns.dark, "") -- and both colours
+ tags = string.gsub(tags, patterns.light, "")
+
+ -- light layer
+ local light_line = util.copy(line)
+ light_line.layer = line.layer + 1
+ local light_tags = string.gsub(tags, "}", "\\bord0\\shad0\\c" .. light .. "}") -- } (end of tag block) --> \cLightColour}
+ light_line.text = light_tags .. text
+ subs[sel[i]] = light_line
+
+ local dark_line = util.copy(line)
+ dark_line.layer = line.layer + 2
+ local dark_tags = string.gsub(tags, "}", "\\bord0\\shad0\\c" .. dark .. "\\blur" .. blur .. "}") -- } -> \cDarkColour\blurBord}
+ dark_line.text = dark_tags .. text
+ subs.insert(sel[i] + 1, dark_line)
+ end
+ end
+ aegisub.set_undo_point(script_name)
+end
+
+if haveDepCtrl then
+ depctrl:registerMacro(main)
+else
+ aegisub.register_macro(script_name, script_description, main)
+end