设置绝对页面大小而不进行渐近线缩放

设置绝对页面大小而不进行渐近线缩放

这不是我第一次尝试解决这个问题,这就是为什么我花了一个小时重新寻找解决方案后,写了一个自答问题。

如何强制 Asymptote 输出具有给定精确页面大小的 PDF 或 EPS,而不管其中绘制了什么图形元素,也不缩放内容?

答案1

用这个:

// Requested page boundaries.
pair page_min = (0mm, 0mm);
pair page_max = (50mm, 10mm);

// Label sticking out of the requested frame.
label("Lorem ipsum", (0, 0), E);

// Line, shorter in one direction of the frame, longer in the other.
draw((0mm, 0mm) -- (20mm, 20mm), 1mm + black);

// Clip the elements in the current picture. Prevents the page from being enlarged and needs to be called after all drawing commands.
clip(box(page_min, page_max));

// Set the page size. Prevents the page from being shrunken.
fixedscaling(page_min, page_max);

相关内容