Skip to content

Commit

Permalink
feat(packages): New scalebox package for arbitrary box re-scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Feb 4, 2023
1 parent 607dcf7 commit 118d412
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/rotate/init.lua
Expand Up @@ -34,13 +34,16 @@ end
-- w Cos[theta]+h Sin[theta] True

local outputRotatedHbox = function (self, typesetter, line)
local outputWidth = SU.rationWidth(self.width, self.width, line.ratio)

local origbox = self.value.orig
local x = self.value.theta
-- Find origin of untransformed hbox
local save = typesetter.frame.state.cursorX
typesetter.frame.state.cursorX = typesetter.frame.state.cursorX - (origbox.width.length-self.width)/2

local horigin = (typesetter.frame.state.cursorX + origbox.width.length / 2):tonumber()
local W = SU.rationWidth(origbox.width, origbox.width, line.ratio)
local horigin = (typesetter.frame.state.cursorX + W.length / 2):tonumber()
local vorigin = -(typesetter.frame.state.cursorY - (origbox.height - origbox.depth) / 2):tonumber()
pdf:gsave()
pdf.setmatrix(1, 0, 0, 1, horigin, vorigin)
Expand All @@ -49,7 +52,7 @@ local outputRotatedHbox = function (self, typesetter, line)
origbox:outputYourself(typesetter, line)
pdf:grestore()
typesetter.frame.state.cursorX = save
typesetter.frame:advanceWritingDirection(self.width)
typesetter.frame:advanceWritingDirection(outputWidth)
end

function package:_init ()
Expand Down

0 comments on commit 118d412

Please sign in to comment.