Docs/Paper sizes
Chitra supports customizing paper sizes in multiple ways. If only the width is provided, a square paper or canvas is created. Standard page sizes, such as A0–A10, B0–B10, and C0–C10, are also supported.
// Standard paper size
auto ctx = new Chitra("a4");
// Standard paper size with landscape orientation
auto ctx = new Chitra("a4,landscape");
// Custom size square paper
auto ctx = new Chitra(400);
// Default size: 700x700 points
auto ctx = new Chitra;
// Custom width and height
auto ctx = new Chitra(1600, 900);
// Using utility functions (4x6 inch photo paper)
auto ctx = new Chitra(4.inch, 6.inch);
// A4 paper in mm
auto ctx = new Chitra(210.mm, 297.mm);
The equivalent code with the Chitra Lua plugin is
-- Standard paper size
size("a4")
-- Standard paper size with landscape orientation
size("a4,landscape")
-- Custom size square paper
size(400)
-- Default size: 700x700 points
-- Not Applicable, skip calling the `size` command
-- Custom width and height
size(1600, 900)
-- Using utility functions (4x6 inch photo paper)
size(inch(4), inch(6))
-- A4 paper in mm
size(mm(210), mm(297))
Once the paper/canvas is created, other commands can retrieve the width and height using the width and height commands. For example, to draw a vertical line in the middle of the paper.
// X1 Y1 X2 Y2
ctx.line(ctx.width / 2, 0, ctx.width / 2, ctx.height / 2);