#ifndef _GRSYS_H_
#define _GRSYS_H_ 1

#include <stdio.h>

#ifndef float64
#define float64 double
#endif

extern float64 grsys_XMin;
extern float64 grsys_XMax;
extern float64 grsys_YMin;
extern float64 grsys_YMax;
extern float64 grsys_XCenter;
extern float64 grsys_YCenter;
extern float64 grsys_RMax;
extern float64 grsys_Density;
extern FILE *grsys_plotFile;
extern int grsys_inGrMode;// bool

void grsys_SetClipBoundaries(float64 x1, float64 x2, float64 y1, float64 y2);
int grsys_clipCode(float64 x, float64 y);
void grsys_ClipDraw(float64 xP, float64 yP, float64 xQ, float64 yQ);
void grsys_SetColor(int c);
void grsys_SetBackgroundColor(int c);
int grsys_GetMaxColor(void);
void grsys_SetRGBPalette(int index, int r, int g, int b);
void grsys_ShadedColors(void);
int grsys_plotCoord(float64 x);
int grsys_IX(float64 x);
int grsys_iy(float64 y);
int grsys_IY(float64 y);
void grsys_Move(float64 x, float64 y);
void grsys_Draw(float64 x, float64 y);
void grsys_PutPix(int x, int y);
void grsys_DrawLine(int xP, int yP, int xQ, int yQ);
void grsys_HorLine(int xLeft, int xRight, int y);
void grsys_Fill(int *X, int *Y);
void grsys_encode(char *filename);
void grsys_Frame(int delay);
void grsys_InitGr(char* filename);
void grsys_EndGr(void);
void grsys_Error(int err);
void grsys_InitWindow(void);
void grsys_UpdateWindowBoundaries(float64 x, float64 y);
void grsys_ViewportBoundaries(float64 Xmin, float64 Xmax, float64 Ymin, float64 Ymax, float64 reductionFactor);
float64 grsys_XViewport(float64 x);
float64 grsys_YViewport(float64 y);
void grsys_AppendPlot(float64 x, float64 y, int code);
void grsys_GenPlot(void);

#include "vec.h"

Vec grsys_Add(Vec u);
Vec grsys_Sub(Vec u);
Vec grsys_Mul(float64 c);
Vec grsys_Rotate(Vec p, Vec c, float64 cosphi, float64 sinphi);

#include "triangul.h"

void grsys_Triangul(int *pol, int n, Trianrs *nrs);

#endif
