-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubpageLayout.cs
28 lines (21 loc) · 936 Bytes
/
SubpageLayout.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
namespace pocketmodise {
using PdfSharp.Drawing;
internal struct SubpageLayout {
public uint X;
public uint Y;
public Facing Upside;
public ISuperpageLayout SuperpageLayout;
public void Transform(XGraphics context, XSize originalSize) {
var sourceWidth = originalSize.Width;
var sourceHeight = originalSize.Height;
var cellWidth = context.PageSize.Width / SuperpageLayout.Columns;
var cellHeight = context.PageSize.Height / SuperpageLayout.Rows;
context.TranslateTransform(X * cellWidth, Y * cellHeight);
context.ScaleTransform(cellWidth, cellHeight);
context.TranslateTransform(0.5, 0.5);
context.RotateTransform(Upside.ToAngle());
context.TranslateTransform(-0.5, -0.5);
context.ScaleTransform(1 / sourceWidth, 1 / sourceHeight);
}
}
}