// PD test program

// Write a little PD file for testing

//BLDR pdtest pdtest1 pdtest2 pdml

external
	[
	PDInit
	PDFinish
	PDRectangle
	PDTrapezoid
	PDSetPos
	PDSetColor
	PDPriority
	PDSetColorP
	PDString

	MulDiv
	]

static resolution=384
static portrait=false

let Main() be
[
// Simple text and rule test
	PDInit("Test0.pd", resolution, portrait)
	PDSetPos(Inches(30), Inches(30))
	PDString("This is a string of text.")
	PDRectangle(Inches(20), Inches(30), Inches(27), Points(3))
	PDFinish()

// Same geometry, different colors
	PDInit("Test1.pd", resolution, portrait)
	PDSetPos(Inches(30), Inches(30))
	PDString("This is a string of text.")
	PDSetColor(30)
	PDRectangle(Inches(20), Inches(30), Inches(27), Points(3))
	PDFinish()

// Complex including colors and priority
	PDInit("Test2.pd", resolution, portrait)
// Vertical, 4 pts wide
	PDRectangle(Inches(10), Points(4), Inches(20), Inches(40))
// Horizontal, 1 in high
	PDRectangle(Inches(10), Inches(60), Inches(70), Inches(10))
// Trapezoid
	PDTrapezoid(Inches(20), Inches(10), Inches(10), Points(10), Inches(20), Inches(10))

	PDSetColorP(30)
	PDRectangle(Inches(10), Inches(60), Inches(60), Points(10))

	PDSetColorP(0)
	PDSetPos(Inches(15), Inches(15))
	PDString("This is PD file output.")

	PDSetColorP(63)
	PDSetPos(Inches(20), Inches(76))
	PDString("White text.")

	PDSetColor(30)
	PDSetPos(Inches(30), Inches(72))
	PDString("Gray text.")
	PDSetPos(Inches(19), Inches(20))
	PDString("More gray text.")

	PDFinish()

// Many lines of text
	PDInit("Test3.pd", resolution, portrait)
	for lines=0 to 59 do
		[
		if portrait ne 0 & lines gr 41 then break
		PDSetPos(Inches(10+(lines rem 10)), Points(34+lines*12))
		PDString("This is a string of text that is long enough to spread across much of the page to measure performance.")
		]
	PDFinish()

// Tiny file for Slot debugging
	PDInit("Test4.pd", resolution, portrait)
	PDSetPos(Inches(30), Inches(30))
	PDString("This")
	PDFinish()

]

// Actually 10'ths of inches

and Inches(i) = MulDiv(i, resolution, 10)

and Points(i) = MulDiv(i, resolution, 72)