#include "PS.hpp"

PS::PS(const char *nom) : std::ofstream (nom)
{
	*this << "%PS 2.0 - Adobe\n"
		<< "8.5 72 mul 2 div 11 72 mul div 2 translate\n"
		<< "72 2.54 div dup scale\n"
		<< "0.03 setlinewidth\n"
		<< "1 setlinecap\n";
		moveto(0,0);	
}

PS::~PS(void)
{
	*this << "stroke\n"
			<< "showpage\n";
}

void PS::moveto(double x, double y)
{
	*this << x << " " << y << " moveto\n";
	X= x;
	Y= y;
}

void PS::lineto(double x, double y)
{
	*this << x << " " << y << " lineto\n";
	X= x;
	Y= y;
}

void PS::setcolor(double r, double g, double b)
{
	*this << "stroke\n";
	*this << r << " " << g << " " << b << " setrgbcolor\n";
	moveto(X,Y);
}


