Skip to content

Prevent slide.asy from stretching paths horizontally#599

Draft
thornoar wants to merge 1 commit into
vectorgraphics:masterfrom
thornoar:fix_slide
Draft

Prevent slide.asy from stretching paths horizontally#599
thornoar wants to merge 1 commit into
vectorgraphics:masterfrom
thornoar:fix_slide

Conversation

@thornoar
Copy link
Copy Markdown

@thornoar thornoar commented May 11, 2026

This line in the slide module introduces a transformation that fits the frame of every slide into the square ranging from (-1,-1) to (1,1):

transform tinv=inverse(fixedscaling((-1,-1),(1,1),currentpen));

At the same time, the picture is sized by size(pagewidth,pageheight,IgnoreAspect), which means that all paths drawn by the user are stretched horizontally by a factor of pagewidth/pageheight.

I understand the benefit of having "unit coordinates" ranging from -1 to 1 in both x and y directions, which makes it easier to place content on the slide, but as soon as the user wants to draw a circle, they have to manually correct it with xscale(pageheight/pagewidth), which leads to other complications, especially if rotation (which does not commute with xscale) is involved.

Of course, if only text and external graphics are included in the presentation (like in the example), this stretching is not a concern. But I think that when typesetting presentation slides, the greatest benefit of Asymptote is the total control it gives the user of the canvas, which alternatives like LaTeX or Typst do not provide.

This behavior seems to be fixed if we create a variable like

real whr = pagewidth/pageheight;

(from "[w]idth-[h]eight [r]atio") and then use (-whr, -1) and (whr, 1) in the definition of tinv:

transform tinv=inverse(fixedscaling((-whr,-1),(whr,1),currentpen));

This pull request makes this change and adjusts some size checks inside slide.asy to use whr instead of 1. I make this a draft because I'm note sure about the preferred naming, and whether pull requests of such nature are approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant