#!/usr/local/bin/ruby
#
#
# ./Minimal.rb

require "ClibPDF"

radius2 = 1.2
xorig = 2.5
yorig = 2.5


pdf = ClibPDF::PDF.open(0)
pdf.enableCompression(ClibPDF::YES)
pdf.init
pdf.pageInit(1, ClibPDF::PORTRAIT, ClibPDF::LETTER, ClibPDF::LETTER)
pdf.translate(0.0, 6.0)

for i in 0..200
  angle = Math::PI * i / 100.0
  x = radius2 * Math.cos(3.0 * angle) + xorig
  y = radius2 * Math.sin(5.0 * angle) + yorig
#  STDERR.print "x: #{x}  y: #{y}\n"
  if i == 0
	pdf.moveto(x, y)
  else
	pdf.lineto(x, y)
  end
end
pdf.closepath
pdf.setrgbcolorFill(1.0, 0.7, 0.7)
pdf.setrgbcolorStroke(0.0, 0.0, 1.0)
pdf.eofillAndStroke

pdf.setgrayFill(0.0)
pdf.beginText(0)
pdf.setFont("Times-Italic", "MacRomanEncoding", 16.0)
pdf.text(1.6, 1.0, 0.0, "x=cos(3t), y=sin(5t)")
pdf.endText

pdf.finalizeAll
pdf.savePDFmemoryStreamToFile("Minimal.pdf")


pdf.close
#pdf.launchPreview
