|
FAUST compiler
0.9.9.6b8
|
#include <PSDev.h>


Public Member Functions | |
| PSDev (const char *, double, double) | |
| ~PSDev () | |
| void | rect (double, double, double, double, const char *, const char *) |
| void | triangle (double x, double y, double l, double h, const char *color, const char *link, bool leftright) |
| void | rond (double, double, double) |
| void | carre (double, double, double) |
| void | fleche (double, double, double, int) |
| void | trait (double, double, double, double) |
| void | dasharray (double, double, double, double) |
| void | text (double, double, const char *, const char *link) |
| void | label (double, double, const char *) |
| void | markSens (double, double, int) |
| void | Error (const char *, const char *, int, double, double, double) |
| PSDev::PSDev | ( | const char * | ficName, |
| double | largeur, | ||
| double | hauteur | ||
| ) |
Definition at line 54 of file PSDev.cpp.
References addFileNum().
{
if ((fic_repr = fopen(addFileNum(ficName),"w+")) == NULL) {
//if ((fic_repr = fopen(ficName,"w+")) == NULL) {
cout<<"Impossible de creer ou d'ouvrir "<<ficName<<endl;
}
if(largeur<hauteur)
largeur=hauteur;
fprintf(fic_repr,"%%!PS-Adobe-3.0 \n");
//fprintf(fic_repr,"%%%%Pages: (atend) \n");
fprintf(fic_repr,"%%%%BoundingBox: 0 0 450 %d\n",(int)floor((hauteur*450/largeur)+1));
fprintf(fic_repr,"/unit {%f mul} def\n\n",450/largeur);
fprintf(fic_repr,"0 %f unit translate\n",hauteur);
fprintf(fic_repr,"1 -1 scale\n\n"); // postscript's origin = lower left corner (SVG:upper left)
fprintf(fic_repr,"0.6 unit setlinewidth\n"); // lines' width
fprintf(fic_repr,"/Times-Roman findfont %% Get the basic font for text\n");
//fprintf(fic_repr,"15 unit scalefont %% Scale the font to 15 units\n");
fprintf(fic_repr,"10 unit scalefont %% Scale the font to 10 units\n");
fprintf(fic_repr,"setfont %% Make it the current font\n\n");
}

| PSDev::~PSDev | ( | ) |
| void PSDev::carre | ( | double | x, |
| double | y, | ||
| double | cote | ||
| ) | [virtual] |
Implements device.
Definition at line 160 of file PSDev.cpp.
{
fprintf(fic_repr,"gsave\n");
fprintf(fic_repr,"newpath\n");
fprintf(fic_repr,"0.3 setgray\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",x-cote/2,y);
fprintf(fic_repr,"0 unit %f unit rlineto\n",-cote);
fprintf(fic_repr,"%f unit 0 unit rlineto\n",cote);
fprintf(fic_repr,"0 unit %f unit rlineto\n",cote);
fprintf(fic_repr,"closepath\n");
fprintf(fic_repr,"stroke\n");
fprintf(fic_repr,"grestore\n");
}
| void PSDev::dasharray | ( | double | x1, |
| double | y1, | ||
| double | x2, | ||
| double | y2 | ||
| ) | [virtual] |
Implements device.
Definition at line 185 of file PSDev.cpp.
{
fprintf(fic_repr,"gsave\n");
fprintf(fic_repr,"newpath\n");
fprintf(fic_repr,"0.6 setgray\n");
fprintf(fic_repr,"0.8 unit setlinewidth\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",x1,y1);
fprintf(fic_repr,"%f unit %f unit lineto\n",x2,y2);
fprintf(fic_repr,"stroke\n");
fprintf(fic_repr,"grestore\n");
}
| void PSDev::Error | ( | const char * | message, |
| const char * | reason, | ||
| int | nb_error, | ||
| double | x, | ||
| double | y, | ||
| double | largeur | ||
| ) | [virtual] |
Implements device.
Definition at line 240 of file PSDev.cpp.
{
fprintf(fic_repr,"gsave\n");
fprintf(fic_repr,"/Times-Roman findfont %% Get the basic font for text\n");
fprintf(fic_repr,"17 unit scalefont %% Scale the font to 10 points\n");
fprintf(fic_repr,"setfont %% Make it the current font\n\n");
fprintf(fic_repr,"newpath\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",(x-8)-(strlen(message)-1)*3.8,y-10);
fprintf(fic_repr,"1 -1 scale\n");
fprintf(fic_repr,"(%s) show\n",message);
fprintf(fic_repr,"1 -1 scale\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",(x-8)-(strlen(reason)-1)*3.8,y+10);
fprintf(fic_repr,"1 -1 scale\n");
fprintf(fic_repr,"(%s) show\n",reason);
fprintf(fic_repr,"grestore\n");
}
| void PSDev::fleche | ( | double | x, |
| double | y, | ||
| double | rotation, | ||
| int | sens | ||
| ) | [virtual] |
Implements device.
Definition at line 124 of file PSDev.cpp.
{
if(sens == 1)
{
fprintf(fic_repr,"gsave\n");
fprintf(fic_repr,"newpath\n");
fprintf(fic_repr,"0.3 setgray\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",x,y);
fprintf(fic_repr,"%f rotate\n",rotation);
fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)-4,(double)-2);
fprintf(fic_repr,"%f rotate\n",(double)-rotation);
fprintf(fic_repr,"%f unit %f unit moveto\n",x,y);
fprintf(fic_repr,"%f rotate\n",rotation);
fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)-4,(double)+2);
fprintf(fic_repr,"closepath\n");
fprintf(fic_repr,"stroke\n");
fprintf(fic_repr,"grestore\n");
}
else //for the recursion
{
fprintf(fic_repr,"gsave\n");
fprintf(fic_repr,"newpath\n");
fprintf(fic_repr,"0.3 setgray\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",x,y);
fprintf(fic_repr,"%f rotate\n",rotation);
fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)4,(double)-2);
fprintf(fic_repr,"%f rotate\n",(double)-rotation);
fprintf(fic_repr,"%f unit %f unit moveto\n",x,y);
fprintf(fic_repr,"%f rotate\n",rotation);
fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)4,(double)+2);
fprintf(fic_repr,"closepath\n");
fprintf(fic_repr,"stroke\n");
fprintf(fic_repr,"grestore\n");
}
}
| void PSDev::label | ( | double | x, |
| double | y, | ||
| const char * | label | ||
| ) | [virtual] |
Implements device.
Definition at line 208 of file PSDev.cpp.
{
fprintf(fic_repr,"gsave\n");
fprintf(fic_repr,"/Times-Roman findfont %% Get the basic font for text\n");
fprintf(fic_repr,"7 unit scalefont %% Scale the font to 10 points\n");
fprintf(fic_repr,"setfont %% Make it the current font\n\n");
fprintf(fic_repr,"newpath\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",(x+2),y+1.2);
fprintf(fic_repr,"1 -1 scale\n");
fprintf(fic_repr,"(%s) show\n",label);
fprintf(fic_repr,"grestore\n");
}
| void PSDev::markSens | ( | double | x, |
| double | y, | ||
| int | sens | ||
| ) | [virtual] |
Implements device.
Definition at line 221 of file PSDev.cpp.
{
if (sens==1)
{
fprintf(fic_repr,"newpath\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",x,y+4);
fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)4,(double)-4);
fprintf(fic_repr,"closepath\n");
}
else //for the recursion
{
fprintf(fic_repr,"newpath\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",x,y-4);
fprintf(fic_repr,"%f unit %f unit rlineto\n",(double)-4,(double)4);
fprintf(fic_repr,"closepath\n");
}
fprintf(fic_repr,"stroke\n");
}
| void PSDev::rect | ( | double | x, |
| double | y, | ||
| double | l, | ||
| double | h, | ||
| const char * | , | ||
| const char * | |||
| ) | [virtual] |
Implements device.
Definition at line 85 of file PSDev.cpp.
{
fprintf(fic_repr,"gsave\n");
fprintf(fic_repr,"newpath\n");
//fprintf(fic_repr,"1.5 unit setlinewidth\n");
fprintf(fic_repr,"1.0 unit setlinewidth\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",x,y);
fprintf(fic_repr,"0 unit %f unit rlineto\n",h);
fprintf(fic_repr,"%f unit 0 unit rlineto\n",l);
fprintf(fic_repr,"0 unit %f unit rlineto\n",-h);
fprintf(fic_repr,"closepath\n");
fprintf(fic_repr,"stroke\n");
fprintf(fic_repr,"grestore\n");
}
| void PSDev::rond | ( | double | x, |
| double | y, | ||
| double | rayon | ||
| ) | [virtual] |
| void PSDev::text | ( | double | x, |
| double | y, | ||
| const char * | nom, | ||
| const char * | link | ||
| ) | [virtual] |
Implements device.
Definition at line 197 of file PSDev.cpp.
{
fprintf(fic_repr,"newpath\n");
//fprintf(fic_repr,"%f unit %f unit moveto\n",(x-4)-(strlen(nom)-1)*3.8,y+2);
fprintf(fic_repr,"%f unit %f unit moveto\n",(x-0)-(strlen(nom)-1)*3.8,y+2);
fprintf(fic_repr,"gsave\n");
fprintf(fic_repr,"1 -1 scale\n\n");
fprintf(fic_repr,"(%s) show\n",nom);
fprintf(fic_repr,"grestore\n");
}
| void PSDev::trait | ( | double | x1, |
| double | y1, | ||
| double | x2, | ||
| double | y2 | ||
| ) | [virtual] |
Implements device.
| void PSDev::triangle | ( | double | x, |
| double | y, | ||
| double | l, | ||
| double | h, | ||
| const char * | color, | ||
| const char * | link, | ||
| bool | leftright | ||
| ) | [virtual] |
Implements device.
Definition at line 100 of file PSDev.cpp.
{
fprintf(fic_repr,"gsave\n");
fprintf(fic_repr,"newpath\n");
//fprintf(fic_repr,"1.5 unit setlinewidth\n");
fprintf(fic_repr,"1.0 unit setlinewidth\n");
fprintf(fic_repr,"%f unit %f unit moveto\n",x,y);
fprintf(fic_repr,"0 unit %f unit rlineto\n",h);
fprintf(fic_repr,"%f unit 0 unit rlineto\n",l);
fprintf(fic_repr,"0 unit %f unit rlineto\n",-h);
fprintf(fic_repr,"closepath\n");
fprintf(fic_repr,"stroke\n");
fprintf(fic_repr,"grestore\n");
}
1.8.0