Skip to content

Commit 6511a60

Browse files
committed
Align:getPositionOffset(): add optional parameter to specify reference alignment
previously the offset was always relative to the coordinate origin (\an7 alignment), now it's possible to use this method to calculate the offset between any given source and target alignment
1 parent e82ad8d commit 6511a60

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

l0/ASSFoundation/Tag/Align.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ return function(ASS, ASSFInst, yutilsMissingMsg, createASSClass, re, util, unico
4545
function Align:isCenterH() return self:getSet("centerH") end
4646
function Align:isRight() return self:getSet("right") end
4747

48-
function Align:getPositionOffset(w, h)
48+
function Align:getPositionOffset(w, h, refAlign)
49+
refAlign = default(refAlign, Align{7})
4950
if ASS:instanceOf(w, ASS.Point, nil, true) then
5051
w, h = w:get()
5152
end
5253
local x, y = {w, 0, w/2}, {h, h/2, 0}
5354
local off = ASS.Point{x[self.value%3+1], y[math.ceil(self.value/3)]}
55+
off:sub(x[refAlign.value%3+1], y[math.ceil(refAlign.value/3)])
56+
5457
return off
5558
end
5659

0 commit comments

Comments
 (0)