#include "PostScript.hpp"

using namespace std;

PostScript::PostScript(const char* nombre) : ofstream(nombre)
{
	*this <<
	"%!PS-Adobe-2.0\n"
	"8.5 2 div 72 mul 11.0 2 div 72 mul translate\n"
	"72 2.54 div dup scale\n"
	"0.01 setlinewidth\n"
	"1 setlinecap\n";
}

PostScript::~PostScript(void) 
{
	*this << 
	"stroke\n"
	"showpage\n";
}

void PostScript::MoveTo(double x, double y)
{
	*this << x << " " << y << " moveto\n";
}

void PostScript::LineTo(double x, double y)
{
	*this << x << " " << y << " lineto\n";
}

void PostScript::SetColor(double r, double g, double b)
{
	*this << "stroke\n";
	*this << r << " " << g << " " << b << " setrgbcolor\n";
}

void PostScript::SetLineWidth(double w)
{
	*this << "stroke\n";
	*this << w << " setlinewidth\n";
}
