This version of the module is deprecated: Use moonbitlang/pdflite instead
flowchart LR
Units[PdfUnit] --> Paper[PaperSize]
Paper --> PageBox[page MediaBox]
Point[Point2] --> Matrix[TransformMatrix]
Ops[TransformOp list] --> Matrix
Matrix --> PointOut[transformed point]///|
test "paper sizes and units are explicit" {
if paper_a4.unit() != Millimetre {
fail("A4 is stored in millimetres")
}
if unit_points(1.0, Inch) != 72.0 {
fail("one inch is 72 PDF points")
}
let landscape = paper_a4.landscape()
if landscape.width() != 297.0 || landscape.height() != 210.0 {
fail("landscape swaps paper width and height")
}
}///|
test "transforms apply to points and render as PDF matrices" {
let moved = transform_translate(5.0, -10.0).apply(point2(10.0, 20.0))
if moved.x != 15.0 || moved.y != 10.0 {
fail("translation should move the point")
}
inspect(
transform_string_of_matrix(transform_translate(5.0, -10.0)),
content="1, 0, 0, 1, 5, -10",
)
}fn transform_append(after : ArrayView[TransformOp], before : ArrayView[TransformOp]) -> Array[TransformOp]fn transform_recompose_components(scale : Double, aspect : Double, rotation : Double, shear : Double, translate_x : Double, translate_y : Double) -> TransformMatrix