egsoftweb@gmail.com
 facebook.com/egsoftweb

Our Products

EG Graphics Library

Version: 1.5


This is an easy graphics library using C++ in windows and was developed in order to provide beginner, novice, expert and advanced C++ programmers for drawing in 2D/3D. We can draw points, lines, triangles, quadrilaterals, rectangles, circles, ellipses, equi-polygons, spiral, pulses, cubes, cones, cylinders, spheres and curves in both XY / R-Theta space using it.

Also we can set properties like shifting, scaling, rotation and parameters like size, position of these objects.

 Sample Code:

//A line between two points.. 
#include "line.h"
#pragma comment(lib,"egMHSL.lib")
int main()
{
        #if defined (WIN32)
        HWND hcon = GetConsoleWindow();
        int pixeldef = eg_USING_INBUILT_FUNCTIONS;
        #elif defined (__MSDOS__)
        int pixeldef = eg_USING_PUTPIXEL;
        #endif
        egSTRUCTGRAPHINFO mygraphinfo(hcon, pixeldef, 40, eGreen);
        egInitGraphics(mygraphinfo);
        #if defined(__MSDOS__)
        mygraphinfo.SetScreenResolution(eg_RESOLUTION_X, eg_RESOLUTION_Y);
              #endif
/////////////////////////////////////////////////////
// start your code from here
               egCLASSPOINTF A(3, 2);
         egCLASSPOINTF B(4, 7);
               egCLASSLINE AB(A, B);
               AB.Draw(mygraphinfo);
               AB.ShowDetails(mygraphinfo);
//////////////////////////////////////////////////////
               _getch();
               egCloseGraphics(mygraphinfo);
               return 0;
}
/*-------------------------------------------------------------------------------------------------------
Explanation of the above sample:
First of all, include required header files.
Link the “egMHSL.lib” file either by #pragma or project setting.
Start writing code with main function.
Define an output window handle for Windows platform (above example contains a console window). Don’t
require it for DOS (turbo compiler).
Define a method of drawing. It may be one of the following macros defined in the “common.h” header:
For Windows:
eg_USING_SETPIXELV
eg_USING_POLYLINE
eg_USING_BUFFER
For DOS:
eg_USING_PUTPIXEL
eg_USING_BUFFER16
For Both (Windows and DOS)
eg_USING_INBUILT_FUNCTIONS
eg_USING_CHARACTER
Note: - It is not require to include “common.h” because this header is all most included in all other header
files.
Take an object of egSTRUCTGRAPHINFO to define information of the output window. This object contains
output window handle (for Only Windows platform), a drawing method, Unit on graph and colour of the graph.
Initialise graph using function egInitGraphics.
Set the screen resolution if you are using DOS.
////////////////////////////////////////////////////////////////////////////////////////////////
Now start your coding to do your objective task. I mean start your drawing code from here
////////////////////////////////////////////////////////////////////////////////////////////////
Close EG Graphics by using egCloseGraphics function. You should not forget to do it.
Return from the main function. Using the Code:
2D drawing:
// define the output graph information
egSTRUCTGRAPHINFO mygraphinfo(hcon, pixeldef, 40, eGreen);
// points
//////////////////////////////////////////////////////////////////////////////////////////
//For integer points
egCLASSPOINTI mypoint(3, 5);
mypoint.Draw(mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
//For float type points
egCLASSPOINTF mypoint(2.76, 4.56);
mypoint.Draw(mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
//line
//////////////////////////////////////////////////////////////////////////////////////////
egCLASSPOINTF A(3, 2);
egCLASSPOINTF B(4, 7);
egCLASSLINE AB(A, B);
AB.Draw(mygraphinfo);
AB.ShowDetails(mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
//triangle//////////////////////////////////////////////////////////////////////////////////////////
egCLASSPOINTF p1(0.0, 0.0);
egCLASSPOINTF p2(2.7, 1.0);
egCLASSPOINTF p3(3.7, -3.0);
egCLASSTRIANGLE my_triangle(p1, p2, p3);
my_triangle.Draw(mygraphinfo);
_getch();
//setting the color of graph
mygraphinfo.SetEGraphColor(eg_COLOR_LIGHTSKY);
my_triangle.Fill(mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
//rectangle
//////////////////////////////////////////////////////////////////////////////////////////
egCLASSRECTANGLE myrect(2, 3, 5, -5);
myrect.Draw(mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
Note: There are many constructors in the class of the object and so we can use any constructor to draw the
object. In above examples we have used one of them.
3D drawing:
// define the output graph information
egSTRUCTGRAPHINFO mygraphinfo(hcon, pixeldef, 40, eGreen);
// define the 3d view structure for projections
egSTRUCTVIEW3D view(0, 90, 45, 1, 1);

// points
//////////////////////////////////////////////////////////////////////////////////////////
//For integer points
egCLASSPOINTI3 mypoint(3, 5, 4);
mypoint.Draw(view, mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
//For float type points
egCLASSPOINTF3 mypoint(2.76, 4.56, -1.9);
mypoint.Draw(view, mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
//line
//////////////////////////////////////////////////////////////////////////////////////////
egCLASSPOINTF3 A(3, 2, 1);
egCLASSPOINTF3 B(4, 7, 5);
egCLASSLINE3 AB(A, B);
AB.Draw(mygraphinfo);
AB.ShowDetails(view, mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
//triangle
//////////////////////////////////////////////////////////////////////////////////////////
egCLASSPOINTF3 p1(0.0, 0.0, 0.0);
egCLASSPOINTF3 p2(2.7, 1.0, 0.7);
egCLASSPOINTF3 p3(3.7, -3.0, -2.5);
egCLASSTRIANGLE3 my_triangle(p1, p2, p3);
my_triangle.Draw(view,mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
//cube
//////////////////////////////////////////////////////////////////////////////////////////
egCLASSPOINTF3 center(0.1, -3.8, 4.5);
double edge = 4.3;
egCLASSCUBE mycube(center, edge);
mycube.Draw(view, mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
//sphere
//////////////////////////////////////////////////////////////////////////////////////////
egCLASSPOINTF3 center(1.1, 2.1, 3.1);
double radius = 4.5;
egCLASSSPHERE my_sphere(center, radius);
my_sphere.Draw(view, mygraphinfo);
//////////////////////////////////////////////////////////////////////////////////////////
------------------------------------------------------------------------------------------------------*/