Render preview banners with transparent patterns correctly #72

Closed
erle wants to merge 3 commits from banner-mask-fix-3 into master
1 changed files with 4 additions and 2 deletions

View File

@ -387,13 +387,15 @@ for colorid, colortab in pairs(mcl_banners.colors) do
-- redraw the pattern textures as low-resolution pixel
-- art and use that instead.
local layer = "(([combine:20x40:-2,-2="..pattern.."^[resize:16x24^[colorize:"..color..":"..layer_ratio.."))"
local layer = "(([combine:20x40:-2,-2=" .. pattern .. "^[resize:16x24^[colorize:" .. color .. ":" .. layer_ratio .. "))"
local mask = "(([combine:20x40:-2,-2=" .. pattern .. "^[resize:16x24" .. "))"
Review

I don't think it's necessary to use two parentheses for either layer or mask here. Probably not worth a commit to fix them, though.

I don't think it's necessary to use two parentheses for either `layer` or `mask` here. Probably not worth a commit to fix them, though.
Review

Please elaborate on that and propose an alternative. I just cargo culted it until it worked.

Please elaborate on that and propose an alternative. I just cargo culted it until it worked.
Review

layer and mask both start with (( and end with )), despite having no intervening parentheses, meaning (at least) one pair of parens is unneeded.

`layer` and `mask` both start with `((` and end with `))`, despite having no intervening parentheses, meaning (at least) one pair of parens is unneeded.
function escape(text)
return text:gsub("%^", "\\%^"):gsub(":", "\\:") -- :gsub("%(", "\\%("):gsub("%)", "\\%)")
end
finished_banner = "[combine:32x32:0,0=" .. escape(base) .. ":8,4=" .. escape(layer)
local layer_masked = layer .. "^[mask:" .. escape(mask)
finished_banner = "[combine:32x32:0,0=" .. escape(base) .. ":8,4=" .. escape(layer_masked)
end
inv = finished_banner